예제 #1
0
        public static void BenchmarkApplication <TAppLauncher>(
            BrowserTimeOptions browserTimeOptions,
            string resultDirectory
            )
            where TAppLauncher : IApplicationLauncher, new()
        {
            resultDirectory             = Path.GetFullPath(resultDirectory);
            var(builder, configuration) = DotvvmTestHost.InitializeBuilder <TAppLauncher>(DotvvmSamplesBenchmarker <TAppLauncher> .GetRootPath());
            var host = builder
                       .UseUrls("http://*:5004")
                       .UseKestrel()
                       .Build();
            var hostCancel = new CancellationTokenSource();
            var hostTask   = host.RunAsync(hostCancel.Token);

            Debug.Assert(configuration.Value != null);
            var hostName = GetLocalHostname();

            Console.WriteLine($"// hostname = {hostName}");
            var urls = DotvvmSamplesBenchmarker <TAppLauncher> .GetTestRoutes(configuration.Value);

            var allResults = new List <(string, BrowserTimeResults)>();

            foreach (var url in urls)
            {
                var absUrl = $"http://{hostName}:5004/{url.TrimStart('/')}";
                Console.WriteLine($"// Benchmarking page load time - {url}");

                try
                {
                    // warm up the server
                    Enumerable.Range(0, 40)
                    .Select(_ => new HttpClient().GetStringAsync(absUrl))
                    .Apply(Task.WhenAll)
                    .Wait();
                    var results = ParseResults(resultDirectory, RunBenchmark(browserTimeOptions, resultDirectory, absUrl), removeDir: true);
                    allResults.Add((url, results));
                    Console.WriteLine($"// Done ({string.Join(", ", results.MeasuredValues.Select(k => k.Key + ": " + k.Value))})");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Benchmarking failed: {ex}");
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
#if RUN_frontend_tests
            FrontendBenchmarker.BenchmarkApplication <DotvvmSamplesLauncher>(new BrowserTimeOptions {
            }, ".");
            return;
#endif

            // Environment.SetEnvironmentVariable("COMPlus_PerfMapEnabled", "1");
            if (Directory.Exists("testViewModels"))
            {
                Directory.Delete("testViewModels", true);
            }

            var conf = CreateTestConfiguration();

            var b = new List <BenchmarkRunInfo>();
#if RUN_synth_tests
            // b.Add(BenchmarkConverter.TypeToBenchmarks(typeof(Benchmarks.RequestBenchmarks), conf));
            b.Add(BenchmarkConverter.TypeToBenchmarks(typeof(Benchmarks.ParserBenchmarks), conf));
            // b.Add(BenchmarkConverter.TypeToBenchmarks(typeof(Benchmarks.SingleControlTests), conf));
#endif
#if RUN_dotvvm_samples
            b.AddRange(DotvvmSamplesBenchmarker <DotvvmSamplesLauncher> .BenchmarkSamples(conf, postRequests: true, getRequests: true));
#endif
#if RUN_perf_samples
            b.AddRange(DotvvmSamplesBenchmarker <DotvvmPerfTestsLauncher> .BenchmarkSamples(conf, getRequests: true, postRequests: true));
            Console.WriteLine("Running with perf samples");
#endif
#if RUN_aspnet_mvc
            b.AddRange(DotvvmSamplesBenchmarker <MvcWebApp.MvcAppLauncher> .BenchmarkMvcSamples(conf));
#endif

            BenchmarkRunner.Run(
                //b.GroupBy(t => t.Parameters.Items.Any(p => p.Name == nameof(DotvvmPostbackBenchmarks<DotvvmSamplesLauncher>.SerializedViewModel))).SelectMany(g => g.Take(27).Skip(25))
                b
                //b.Take(1)
                .ToArray());
        }