public static void Profile() { var sw = new Stopwatch(); var samples = new EvaluatorSamples(); var count = 20; var inxed = 0; bool preventCaching = false; Action run = () => { sw.Restart(); for (int i = 0; i < count; i++) { if (preventCaching) { samples.PerformanceTest(inxed++); } else { samples.PerformanceTest(); } } Console.WriteLine(CSScript.Evaluator.GetType().Name + ": " + sw.ElapsedMilliseconds); }; Action runAll = () => { Console.WriteLine(); Console.WriteLine("---------------------------------------------"); Console.WriteLine("Caching enabled: " + preventCaching); Console.WriteLine(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; run(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; run(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; run(); }; RoslynEvaluator.LoadCompilers(); //Roslyn is extremely heavy so exclude startup time from profiling Console.WriteLine("Testing performance"); preventCaching = true; runAll(); preventCaching = false; runAll(); }
public static void Profile() { var sw = new Stopwatch(); var samples = new EvaluatorSamples(); var count = 20; var inxed = 0; bool preventCaching = false; Action run = () => { sw.Restart(); for (int i = 0; i < count; i++) { if (preventCaching) { samples.PerformanceTest(inxed++); } else { samples.PerformanceTest(); } } Console.WriteLine(CSScript.Evaluator.GetType().Name + ": " + sw.ElapsedMilliseconds); }; Action runAll = () => { Console.WriteLine("\n---------------------------------------------"); Console.WriteLine($"Caching enabled: {!preventCaching}\n"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; run(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; run(); }; Console.WriteLine("Testing performance"); preventCaching = true; runAll(); preventCaching = false; runAll(); }
public static void Profile() { var sw = new Stopwatch(); var samples = new EvaluatorSamples(); var count = 20; var inxed = 0; bool preventCaching = false; Action run = () => { sw.Restart(); for (int i = 0; i < count; i++) if (preventCaching) samples.PerformanceTest(inxed++); else samples.PerformanceTest(); Console.WriteLine(CSScript.Evaluator.GetType().Name + ": " + sw.ElapsedMilliseconds); }; Action runAll = () => { Console.WriteLine("\n---------------------------------------------"); Console.WriteLine($"Caching enabled: {!preventCaching}\n"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; run(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; run(); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; run(); }; RoslynEvaluator.LoadCompilers(); //Roslyn is extremely heavy so exclude startup time from profiling Console.WriteLine("Testing performance"); preventCaching = true; runAll(); preventCaching = false; runAll(); }