public static void RunTest() { for (int i = 0; i < 10; i++) { TestMethod(); } for (int m = 0; m < 3; m++) { ProfilerTst.SetProfiler(null); Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < 500000000; i++) { TestMethod(); } sw.Stop(); ProfilerTst.SetProfiler(new ProfilerTest()); //System.Diagnostics.Debugger.Launch(); Stopwatch sw2 = Stopwatch.StartNew(); for (int i = 0; i < 500000000; i++) { TestMethod(); } sw2.Stop(); Console.WriteLine($"Loop 1: {sw.ElapsedMilliseconds}ms, Loop 2: {sw2.ElapsedMilliseconds}ms"); } }
private static void TestMethod() { _incVar++; ProfilerTst.Method("a"); _incVar--; }