Esempio n. 1
0
        private void WritePhaseData(StreamWriter sw, PhaseDurationData d, string start, string complete)
        {
            string dtPattern = "yyyy-MM-dd HH:mm:ss.fff";

            sw.WriteLine($"Время {start}: {d.FirstStartTime.ToString(dtPattern)}, в мс. с начала нагрузочного теста: {d.FirstStartMs}");
            sw.WriteLine($"Время {complete}: {d.LastCompleteTime.ToString(dtPattern)}, в мс. с начала нагрузочного теста: {d.LastCompleteMs}");
            sw.WriteLine($"Время в мс. с {start} до {complete}: {d.Duration}");
            sw.WriteLine($"Минимальная продолжителость фазы для одного запроса (мс): {d.MinDuration}");
            sw.WriteLine($"Максимальная продолжителость фазы для одного запроса (мс): {d.MaxDuration}");
            sw.WriteLine($"Средняя продолжительность фазы для одного запроса (мс): {d.AverageDuration}");
            sw.WriteLine($"Медианная продолжительность фазы для одного запроса (мс): {d.MedianDuration}");
        }
Esempio n. 2
0
        private PhaseDurationData GetPhaseDurationData(WiEventType start, WiEventType complete)
        {
            DateTime?minStartTime    = null;
            DateTime?maxCompleteTime = null;
            long?    minStartEm      = null;
            long?    maxCompleteEm   = null;

            List <long> durationList = new List <long>();

            foreach (WorkItemData wid in _wiDataList)
            {
                WiTestEvent se = wid.Events.FirstOrDefault(e => e.Type == start);
                WiTestEvent ce = wid.Events.FirstOrDefault(e => e.Type == complete);
                if (se != null && ce != null)
                {
                    durationList.Add(ce.GlobalElapsedMilliseconds - se.GlobalElapsedMilliseconds);

                    if (!minStartTime.HasValue || minStartTime.Value > se.Dt)
                    {
                        minStartTime = se.Dt;
                    }

                    if (!maxCompleteTime.HasValue || maxCompleteTime.Value < ce.Dt)
                    {
                        maxCompleteTime = ce.Dt;
                    }

                    if (!minStartEm.HasValue || minStartEm.Value > se.ElapsedMilliseconds.Value)
                    {
                        minStartEm = se.ElapsedMilliseconds;
                    }

                    if (!maxCompleteEm.HasValue || maxCompleteEm.Value < ce.ElapsedMilliseconds.Value)
                    {
                        maxCompleteEm = ce.ElapsedMilliseconds;
                    }
                }
            }

            if (durationList.Count == 0)
            {
                return(null);
            }

            durationList.Sort();
            long    medianDuration = ((durationList.Count % 2) == 1 ? durationList[(durationList.Count - 1) / 2] : (durationList[durationList.Count / 2 - 1] + durationList[durationList.Count / 2]) / 2);
            decimal avgDuration    = Math.Round(new decimal(durationList.Average()), 3);

            PhaseDurationData data = new PhaseDurationData
            {
                FirstStartTime   = minStartTime.Value,
                LastCompleteTime = maxCompleteTime.Value,
                Duration         = maxCompleteEm.Value - minStartEm.Value,
                FirstStartMs     = minStartEm.Value,
                LastCompleteMs   = maxCompleteEm.Value,
                MinDuration      = durationList.First(),
                MaxDuration      = durationList.Last(),
                MedianDuration   = medianDuration,
                AverageDuration  = avgDuration
            };

            return(data);
        }
Esempio n. 3
0
        private ReportData PrepareReportData(ConfigReportData crd)
        {
            ReportData ed = new ReportData();

            ed.ConfigParameters = crd;

            long?prepare = GetDuration(EventType.PrepareTestStart, EventType.PrepareTestEnd);
            long?runTest = GetDuration(EventType.RunTestStart, EventType.RunTestEnd);
            long?connect = GetDuration(EventType.CreateThreadsAndConnectStart, EventType.CreateThreadsAndConnectEnd);
            long?request = GetDuration(EventType.SendRequestsStart, EventType.SendRequestsEnd);
            long?convert = GetDuration(EventType.Tcp2HttpResponsesConversionStart, EventType.Tcp2HttpResponsesConversionEnd);
            ExecutionReportDurationData dd = new ExecutionReportDurationData
            {
                Overall = _globalEvents.Last().GlobalElapsedMilliseconds,
                Prepare = prepare,
                RunTest = runTest,
                Connect = connect,
                Request = request,
                Convert = convert
            };

            ed.ExecutionReport = new ExecutionReportData
            {
                Started   = _globalStartDt,
                Completed = _globalEvents.Last().Dt,
                DurationInMilliseconds = dd
            };

            int         failedOnConnect        = _wiDataList.Count(d => d.ConnectionFailed);
            int         failedOnRequest        = _wiDataList.Count(d => d.RequestFailed);
            int         failedOnConvert        = _wiDataList.Count(d => d.ConvertFailed);
            List <long> responsesAppearedTimes = _wiDataList.Select(d => d.Events.FirstOrDefault(e => e.Type == WiEventType.FirstBlockReceived)?.ElapsedMilliseconds)
                                                 .Where(em => em.HasValue).Select(em => em.Value).ToList();
            long?firstResponseAppeared = (responsesAppearedTimes.Count == 0 ? (long?)null : responsesAppearedTimes.Min());
            long?lastResponseAppeared  = (responsesAppearedTimes.Count == 0 ? (long?)null : responsesAppearedTimes.Max());

            PhaseDurationData connectDuration = GetPhaseDurationData(WiEventType.Connection, WiEventType.Connected);
            PhaseDurationData sendDuration    = GetPhaseDurationData(WiEventType.RequestStarted, WiEventType.RequestSent);
            PhaseDurationData receiveDuration = GetPhaseDurationData(WiEventType.RequestSent, WiEventType.Received);
            PhaseDurationData convertDuration = GetPhaseDurationData(WiEventType.ConversionStarted, WiEventType.ConversionCompleted);

            ed.TestMetrics = new TestMetricsData
            {
                SuccessOnConnect = crd.Threads - failedOnConnect,
                SuccessOnRequest = crd.Threads - failedOnConnect - failedOnRequest,
                ErrorsOnConnect  = failedOnConnect,
                ErrorsOnRequest  = failedOnRequest,
                ConnectDuration  = connectDuration,
                SendDuration     = sendDuration,
                ReceiveDuration  = receiveDuration,
                FirstResponseAppearedAfterTestStarted = firstResponseAppeared,
                LastResponseAppearedAfterTestStarted  = lastResponseAppeared
            };

            ed.ConvertMetrics = new ConvertMetricsData
            {
                SuccessOnConvert = crd.Threads - failedOnConnect - failedOnRequest,
                ErrorsOnConvert  = failedOnConvert,
                ConvertDuration  = convertDuration
            };

            return(ed);
        }