Ejemplo n.º 1
0
        public void OnGet(int iterations = 1000)
        {
            Stopwatch total = Stopwatch.StartNew();

            double runMs = 0;

            for (int i = 0; i < iterations; i++)
            {
                Stopwatch runTime = Stopwatch.StartNew();

                var response = _studentApi.GetStudents().GetAwaiter().GetResult();

                runTime.Stop();

                if (response.WasNotSuccessful() || response.Data == null)
                {
                    throw new NullReferenceException();
                }

                runMs += runTime.Elapsed.TotalMilliseconds;
            }

            total.Stop();

            Iterations           = iterations;
            RunTime              = Math.Round(total.Elapsed.TotalMilliseconds, 3);
            ExecutionTime        = Math.Round(runMs, 3);
            AverageRunTime       = Math.Round(total.Elapsed.TotalMilliseconds / iterations, 3);
            AverageExecutionTime = Math.Round(runMs / iterations, 3);
        }