コード例 #1
0
        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
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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
        }
コード例 #4
0
        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
        }
コード例 #5
0
        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();
        }
コード例 #6
0
ファイル: Scripting.evaluator.cs プロジェクト: lsw8724/NCC
        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();
        }
コード例 #7
0
        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();
        }