Created
May 23, 2018 04:43
-
-
Save gladiatorAsh/57045f27358ffd0ba2441a01068d20d1 to your computer and use it in GitHub Desktop.
Simple Measurement in C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static void Measure(string what, int reps, Action action){ | |
| action(); //Warmup | |
| double[] results=new double[reps]; | |
| for(int i=0;i<reps;i++){ | |
| StopWatch sw= StopWatch.StartNew(); | |
| action(); | |
| results[i]=sw.Elapsed.TotalMilliseconds; | |
| } | |
| Console.WriteLine("{0} - AVG = {1}, {2} = MIN, {3} = MAX", | |
| what, results.Average(), results.Min(),rsults.Max()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment