示例#1
0
        private void PostIteration(ScenarioExecutionResult scenarioExecutionResult)
        {
            PrintHeader("Processing iteration results.");

            double?startupTime            = null;
            double?firstRequestTime       = null;
            double?steadyStateAverageTime = null;

            using (var reader = new StringReader(_stdout.ToString()))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    Match match = Regex.Match(line, @"^Server started in (\d+)ms$");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        startupTime = Convert.ToDouble(match.Groups[1].Value);
                        continue;
                    }

                    match = Regex.Match(line, @"^Request took (\d+)ms$");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        firstRequestTime = Convert.ToDouble(match.Groups[1].Value);
                        continue;
                    }

                    match = Regex.Match(line, @"^Steadystate average response time: (\d+)ms$");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        steadyStateAverageTime = Convert.ToDouble(match.Groups[1].Value);
                        break;
                    }
                }
            }

            if (!startupTime.HasValue)
            {
                throw new Exception("Startup time was not found.");
            }
            if (!firstRequestTime.HasValue)
            {
                throw new Exception("First Request time was not found.");
            }
            if (!steadyStateAverageTime.HasValue)
            {
                throw new Exception("Steady state average response time not found.");
            }

            IterationsData.Add(new IterationData {
                ScenarioExecutionResult = scenarioExecutionResult,
                StandardOutput          = _stdout.ToString(),
                StartupTime             = startupTime.Value,
                FirstRequestTime        = firstRequestTime.Value,
                SteadystateTime         = steadyStateAverageTime.Value,
            });

            PrintRunningStepInformation($"({IterationsData.Count}) Server started in {IterationsData.Last().StartupTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Request took {IterationsData.Last().FirstRequestTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Cold start time (server start + first request time): {IterationsData.Last().StartupTime + IterationsData.Last().FirstRequestTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Average steady state response {IterationsData.Last().SteadystateTime}ms");

            _stdout.Clear();
            _stderr.Clear();
        }
示例#2
0
        private void PostIteration(ScenarioExecutionResult scenarioExecutionResult)
        {
            PrintHeader("Processing iteration results.");

            double?startupTime            = null;
            double?firstRequestTime       = null;
            double?steadyStateAverageTime = null;
            double?steadyStateMedianTime  = null;

            using (var reader = new StringReader(_stdout.ToString()))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    Match match = Regex.Match(line, @"^Server start \(ms\): \s*(\d+)\s*$");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        startupTime = Convert.ToDouble(match.Groups[1].Value);
                        continue;
                    }

                    match = Regex.Match(line, @"^1st Request \(ms\): \s*(\d+)\s*$");
                    if (match.Success && match.Groups.Count == 2)
                    {
                        firstRequestTime = Convert.ToDouble(match.Groups[1].Value);
                        continue;
                    }

                    //the steady state output chart looks like:
                    //   Requests    Aggregate Time(ms)    Req/s   Req Min(ms)   Req Mean(ms)   Req Median(ms)   Req Max(ms)   SEM(%)
                    // ----------    ------------------    -----   -----------   ------------   --------------   -----------   ------
                    //    2-  100                 5729   252.60          3.01           3.96             3.79          9.81     1.86
                    //  101-  250                 6321   253.76          3.40           3.94             3.84          5.25     0.85
                    //  ... many more rows ...

                    //                              Requests       Agg     req/s        min          mean           median         max          SEM
                    match = Regex.Match(line, @"^\s*\d+-\s*\d+ \s* \d+ \s* \d+\.\d+ \s* \d+\.\d+ \s* (\d+\.\d+) \s* (\d+\.\d+) \s* \d+\.\d+ \s* \d+\.\d+$");
                    if (match.Success && match.Groups.Count == 3)
                    {
                        //many lines will match, but the final values of these variables will be from the last batch which is presumably the
                        //best measurement of steady state performance
                        steadyStateAverageTime = Convert.ToDouble(match.Groups[1].Value);
                        steadyStateMedianTime  = Convert.ToDouble(match.Groups[2].Value);
                        continue;
                    }
                }
            }

            if (!startupTime.HasValue)
            {
                throw new Exception("Startup time was not found.");
            }
            if (!firstRequestTime.HasValue)
            {
                throw new Exception("First Request time was not found.");
            }
            if (!steadyStateAverageTime.HasValue)
            {
                throw new Exception("Steady state average response time not found.");
            }
            if (!steadyStateMedianTime.HasValue)
            {
                throw new Exception("Steady state median response time not found.");
            }

            IterationsData.Add(new IterationData
            {
                ScenarioExecutionResult = scenarioExecutionResult,
                StandardOutput          = _stdout.ToString(),
                StartupTime             = startupTime.Value,
                FirstRequestTime        = firstRequestTime.Value,
                SteadystateTime         = steadyStateAverageTime.Value,
                SteadystateMedianTime   = steadyStateMedianTime.Value,
            });

            PrintRunningStepInformation($"({IterationsData.Count}) Server started in {IterationsData.Last().StartupTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Request took {IterationsData.Last().FirstRequestTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Cold start time (server start + first request time): {IterationsData.Last().StartupTime + IterationsData.Last().FirstRequestTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Average steady state response {IterationsData.Last().SteadystateTime}ms");
            PrintRunningStepInformation($"({IterationsData.Count}) Median steady state response {IterationsData.Last().SteadystateMedianTime}ms");

            _stdout.Clear();
            _stderr.Clear();
        }