public static void Test() { // Just in case clear AlternativeCompiler so it is not set to Roslyn or anything else by // the CS-Script installed (if any) on the host OS CSScript.GlobalSettings.UseAlternativeCompiler = null; var samples = new EvaluatorSamples(); Console.WriteLine("Testing compiling services"); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); //samples.DebugTest(); //uncomment if want to fire an assertion during the script execution //Profile(); //uncomment if want to test performance of the engines }
public static void Test() { var samples = new EvaluatorSamples(); Console.WriteLine("Testing compiling services"); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Mono; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.Roslyn; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); Console.WriteLine("---------------------------------------------"); CSScript.EvaluatorConfig.Engine = EvaluatorEngine.CodeDom; Console.WriteLine(CSScript.Evaluator.GetType().Name + "..."); samples.RunAll(); //samples.DebugTest(); //uncomment if want to fire an assertion during the script execution //Profile(); //uncomment if want to test performance of the engines }
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(); }