Пример #1
0
        public void TestPerformance()
        {
            string[] tests = { "access-binary-trees" };
            // string[] tests = { "3d-cube", "3d-morph", "3d-raytrace", "access-binary-trees", "access-fannkuch", "access-nbody", "access-nsieve", "bitops-3bit-bits-in-byte", "bitops-bits-in-byte", "bitops-bitwise-and", "bitops-nsieve-bits", "controlflow-recursive", "crypto-aes", "crypto-md5", "crypto-sha1", "date-format-tofte", "date-format-xparb", "math-cordic", "math-partial-sums", "math-spectral-norm", "regexp-dna", "string-base64", "string-fasta", "string-tagcloud", "string-unpack-code", "string-validate-input" };

            var       assembly = Assembly.GetExecutingAssembly();
            Stopwatch sw       = new Stopwatch();

            foreach (var test in tests)
            {
                string script;

                try
                {
                    script = new StreamReader(assembly.GetManifestResourceStream("Jint.Tests.SunSpider." + test + ".js")).ReadToEnd();
                    if (String.IsNullOrEmpty(script))
                    {
                        continue;
                    }
                }
                catch
                {
                    Console.WriteLine("{0}: ignored", test);
                    continue;
                }

                JintEngine jint = Fixtures.CreateJintEngine()
                                  //.SetDebugMode(true)
                                  .DisableSecurity();

                sw.Reset();
                sw.Start();

                jint.Run(script);

                Console.WriteLine("{0}: {1}ms", test, sw.ElapsedMilliseconds);
            }
        }