Reset() public method

public Reset ( ) : void
return void
Esempio n. 1
0
        public static double BenchmarkTime(Action action, int iterationsPerSample = 1, int sampleCount = 5)
        {
            //clean Garbage
            GC.Collect();

            //wait for the finalizer queue to empty
            GC.WaitForPendingFinalizers();

            //clean Garbage
            GC.Collect();

            //warm up
            action();

            var watch   = new TimeWatch();
            var timings = new double[sampleCount];

            for (var i = 0; i < timings.Length; i++)
            {
                watch.Reset();
                watch.Start();
                for (var j = 0; j < iterationsPerSample; j++)
                {
                    action();
                }
                watch.Stop();
                timings[i] = watch.Elapsed.TotalMilliseconds;
            }
            return(timings.NormalizedMean());
        }
Esempio n. 2
0
        public static double BenchmarkTime(Action action, int iterationsPerSample = 1, int sampleCount = 5)
        {
            //clean Garbage
            GC.Collect();

            //wait for the finalizer queue to empty
            GC.WaitForPendingFinalizers();

            //clean Garbage
            GC.Collect();

            //warm up
            action();

            var watch = new TimeWatch();
            var timings = new double[sampleCount];
            for (var i = 0; i < timings.Length; i++)
            {
                watch.Reset();
                watch.Start();
                for (var j = 0; j < iterationsPerSample; j++)
                    action();
                watch.Stop();
                timings[i] = watch.Elapsed.TotalMilliseconds;
            }
            return timings.NormalizedMean();
        }