예제 #1
0
        /// <summary>Runs this instance.</summary>
        /// <returns>Run results.</returns>
        /// <exception cref="InvalidOperationException">You must call PreAllocate() and Jitting() first!</exception>
        public RunResults Run()
        {
            if (!_isJitted || !_isPreAllocated)
            {
                throw new InvalidOperationException("You must call PreAllocate() and Jitting() first!");
            }

            _isPreAllocated = false;

            if (Strategy != RunStrategy.ColdStart)
            {
                if (EvaluateOverhead)
                {
                    RunCore(IterationMode.IdleWarmup, WarmupCount, IdleWarmupList);
                }
                RunCore(IterationMode.MainWarmup, WarmupCount, WarmupList);
            }

            if (EvaluateOverhead)
            {
                RunCore(IterationMode.IdleTarget, TargetCount, IdleTargetList);
            }
            RunCore(IterationMode.MainTarget, TargetCount, TargetList);

            var results = new RunResults(
                (IdleTargetList?.Count ?? 0) == 0 ? null : IdleTargetList,
                TargetList,
                RemoveOutliers,
                new GcStats());

            if (!IsDiagnoserAttached)
            {
                foreach (var measurement in IdleWarmupList)
                {
                    Console.WriteLine(measurement.ToOutputLine());
                }
                foreach (var measurement in WarmupList)
                {
                    Console.WriteLine(measurement.ToOutputLine());
                }
                if (IdleTargetList != null)
                {
                    foreach (var measurement in IdleTargetList)
                    {
                        Console.WriteLine(measurement.ToOutputLine());
                    }
                }
                foreach (var measurement in TargetList)
                {
                    Console.WriteLine(measurement.ToOutputLine());
                }
            }

            return(results);
        }
예제 #2
0
 public void ReportResults(RunResults runResults) => runResults.Print(outWriter);