Exemple #1
0
        public void Bench(string name, int iterations, BenchMethod method)
        {
            method(iterations);             // Warm up
            var s = Stopwatch.StartNew();

            method(iterations);
            Console.WriteLine(name + ": " + (s.Elapsed.TotalMilliseconds / iterations) * 1000000 + " ns");
        }
Exemple #2
0
        public void Bench(string name, int iterations, int timesMethodIterated, BenchMethod method)
        {
            method(iterations);             // Warm up
            var s = Stopwatch.StartNew();

            for (int i = 0; i < timesMethodIterated; i++)
            {
                method(iterations);
            }
            Console.WriteLine(name + ": " + (s.Elapsed.TotalMilliseconds / iterations / timesMethodIterated) * 1000000 + " ns");
        }