static PerformaceTestResult PerfTest(bool enableFileWatcher, bool enableCompilation, bool disableGlobalMembers)
        {
            var       result = new PerformaceTestResult();
            Stopwatch init   = new Stopwatch();

            init.Start();

            using (var runner =
                       new ReactRunner(@"D:\work\Olympic\BookingEngine\Build\Olympic.BookingEngine\assets\js\bundle.js",
                                       enableFileWatcher, enableCompilation, disableGlobalMembers, "global.SuperChargedReact.bootstrapper", new JsonSerializerSettings()))
            {
                init.Stop();

                result.InitializationTime = init.ElapsedMilliseconds;

                var times = new List <long>();
                Console.WriteLine("Benchmarking html generation");
                var props = File.ReadAllText("props.json");

                for (int i = 0; i < 20; i++)
                {
                    init.Reset();
                    string outputStr = "";
                    init.Start();
                    ReactPerformaceMeasurements measurements;
                    var settings = new RenderSettings("reactApp", new { testString = "testString" }, "/search/AccommodationOnly");
                    runner.Execute(settings, out outputStr, out measurements);
                    init.Stop();
                    times.Add(init.ElapsedMilliseconds);
                    //    Console.WriteLine(init.ElapsedMilliseconds);
                }

                result.Iterations = times.Count;
                result.Average    = times.Average();
                result.First5GenerationsAverage = times.Take(5).Average();
                result.Last10GenerationsAverage = times.Skip(times.Count - 10).Average();

                result.QuickestGeneration = times.Min();
                result.LongestGeneration  = times.Max();
            }
            return(result);
        }
Exemple #2
0
        static void ThreadChecker()
        {
            var runner = new ReactRunner(@"C:\Users\Stephen\Documents\visual studio 2013\Projects\Orc.SuperchargedReact\Orc.SuperchargedReact.ExampleBundle\bundle.js", true, true, true, new JsonSerializerSettings());

            Parallel.For(0, 100, new ParallelOptions()
            {
                MaxDegreeOfParallelism = 50
            }, (i, state) =>
            {
                Console.WriteLine("Starting:" + i);
                var testString    = "helloWorld" + i;
                var browserOutput = "";
                ReactPerformaceMeasurements measurements;
                var output = runner.Execute("reactApp", "/tester", new { testString = testString }, out browserOutput, out measurements);
                if (!output.Contains(testString))
                {
                    throw new Exception("Not Thread Safe.... uh oh!");
                }
                Console.WriteLine("Complete:" + i);
            });
        }