public static void Run() { // Initialize LoadRunnerEngine by providing: // * Type of class which implements ILoadTestScenario (e.g DemoTestScenario) // * LoadRunnerParameters // * As many aggregators as you like HistogramAggregator histogramAggregator = AggregationSetup.Build(); LoadRunnerParameters parameters = ParametersSetup.Build(); LoadRunnerEngine loadRunner = LoadRunnerEngine.Create <DemoTestScenario>(parameters, histogramAggregator); // Run test (blocking call) loadRunner.Run(); // Once finished, extract information from used aggregators, and do some exceling :) // BuildResultsObjects() will produce results in structure compatible with JSON -> CSV converters. (See ~20 lines below) IEnumerable <object> defaultResults = histogramAggregator.BuildResultsObjects(); Console.WriteLine(JsonConvert.SerializeObject(defaultResults, Formatting.Indented)); Console.ReadKey(); //Alternative export way is // HistogramResults results = histogramAggregator.BuildResults(); // // results will be presented in this structure: // * string[] ColumnNames; // * object[][] Values; }
public static void Run() { StrategyBuilder strategy = new StrategyBuilder() .SetScenario(new Factory()) // Use own custom scenario factory .SetLimit(new TimeLimit(TimeSpan.FromSeconds(5))) .SetThreading(new FixedThreadCount(4)); LoadRunnerEngine engine = strategy.Build(); engine.Run(); Console.ReadKey(); }
public static void Run() { CountingScenarioFactory scenarioFactory = new CountingScenarioFactory(); StrategyBuilder strategy = new StrategyBuilder() .SetScenario(scenarioFactory) .SetThreading(new FixedThreadCount(4)) .SetLimit(new TimeLimit(TimeSpan.FromSeconds(10))); // Increase TimeLimit precision LoadRunnerEngine engine = strategy.Build(); engine.HeartBeatMs = 1; Stopwatch watch = new Stopwatch(); watch.Start(); engine.Run(); watch.Stop(); scenarioFactory.PrintSum(); Console.WriteLine($@"TPS {scenarioFactory.GetSum() / watch.Elapsed.TotalSeconds:N}"); Console.WriteLine(watch.Elapsed.ToString("g")); /* * i5-4670 * * Unoptimized build * 0 15887088 * 1 13794690 * 2 16120714 * 3 13965244 * ------- * 59767736 * TPS 5 873 963,09 * * Optimized build * 0:00:10,0204332 * 0 20196083 * 1 20441812 * 2 20276545 * 3 20205667 * ------- * 81120107 * TPS 8 095 469,07 */ }
public static void Run() { // [2] Results aggregation (Or raw measurement collection, see RawDataMeasurementsDemo.cs) // Define how data gets aggregated. // Dimensions are like GROUP BY keys in SQL // Metrics are aggregation functions like COUNT, SUM, etc.. // Extensive HistogramAggregator demo now WiP HistogramAggregator aggregator = new HistogramAggregator() .Add(new TimeDimension(TimeSpan.FromSeconds(5))) .Add(new CountMetric()) .Add(new ErrorCountMetric()) .Add(new TransactionsPerSecMetric()) .Add(new PercentileMetric(0.95, 0.99)); // Secondary aggregation just to monitor key metrics. KpiPrinterAggregator kpiPrinter = new KpiPrinterAggregator( TimeSpan.FromSeconds(5), new CountMetric(Checkpoint.NotMeassuredCheckpoints), new ErrorCountMetric(false), new TransactionsPerSecMetric() ); // [3] Execution settings // Using StrategyBuilder put defined aggregation, scenario, and execution settings into one object StrategyBuilder strategy = new StrategyBuilder() .SetAggregator(aggregator, kpiPrinter) // Optional .SetScenario <BlankScenario>() // Required .SetLimit(new TimeLimit(TimeSpan.FromSeconds(20))) // Optional, but if not provided, execution will never stop - unless running test with RunAsync() and stopping later with CancelAsync(true) .SetSpeed(new FixedSpeed(100000)) // Optional (Skip for maximum throughput) .SetThreading(new FixedThreadCount(4)); // Required // [4] Execution // All that's left is Build(), run and wait for completion and print out measured results. LoadRunnerEngine engine = strategy.Build(); engine.Run(); IEnumerable <object> result = aggregator.BuildResultsObjects(); Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented)); }
public static void Run() { CountingScenarioFactory scenarioFactory = new CountingScenarioFactory(); StrategyBuilder strategy = new StrategyBuilder() .SetScenario(scenarioFactory) .SetThreading(new FixedThreadCount(4)) .SetLimit(new TimeLimit(TimeSpan.FromSeconds(10))); // Increase TimeLimit precision LoadRunnerEngine engine = strategy.Build(); engine.HeartBeatMs = 1; Stopwatch watch = new Stopwatch(); watch.Start(); engine.Run(); watch.Stop(); scenarioFactory.PrintSum(); Console.WriteLine($@"TPS {scenarioFactory.GetSum() / watch.Elapsed.TotalSeconds:N}"); Console.WriteLine(watch.Elapsed.ToString("g")); }