diff --git a/examples/Demo/Demo.csproj b/examples/Demo/Demo.csproj index 78e4bb85..4961c422 100644 --- a/examples/Demo/Demo.csproj +++ b/examples/Demo/Demo.csproj @@ -39,7 +39,7 @@ <PackageReference Include="Bogus" Version="34.0.2" /> <PackageReference Include="Dapper.Contrib" Version="2.0.78" /> <PackageReference Include="LiteDB" Version="5.0.15" /> - <PackageReference Include="NBomber" Version="5.3.0" /> + <PackageReference Include="NBomber" Version="5.4.0" /> <PackageReference Include="NBomber.Data" Version="5.0.0" /> <PackageReference Include="NBomber.Http" Version="5.0.0" /> <PackageReference Include="NBomber.Sinks.InfluxDB" Version="5.0.1" /> diff --git a/examples/Demo/HelloWorld/HelloWorldExample.cs b/examples/Demo/HelloWorld/HelloWorldExample.cs index 8aa088b9..4ee13928 100644 --- a/examples/Demo/HelloWorld/HelloWorldExample.cs +++ b/examples/Demo/HelloWorld/HelloWorldExample.cs @@ -17,7 +17,7 @@ public void Run() }) .WithoutWarmUp() .WithLoadSimulations( - Simulation.Inject(rate: 1, interval: TimeSpan.FromSeconds(1), during: TimeSpan.FromSeconds(30)) // keep injecting with rate 150 + Simulation.Inject(rate: 150, interval: TimeSpan.FromSeconds(1), during: TimeSpan.FromSeconds(30)) // keep injecting with rate 150 ); NBomberRunner diff --git a/examples/Demo/HelloWorld/LoadSimulation/ScenarioTotalIterations.cs b/examples/Demo/HelloWorld/LoadSimulation/ScenarioTotalIterations.cs new file mode 100644 index 00000000..beba504c --- /dev/null +++ b/examples/Demo/HelloWorld/LoadSimulation/ScenarioTotalIterations.cs @@ -0,0 +1,27 @@ +using NBomber.CSharp; + +namespace Demo.HelloWorld.LoadSimulation; + +public class ScenarioTotalIterations +{ + public void Run() + { + var scenario = Scenario.Create("hello_world_scenario", async context => + { + await Task.Delay(1_000); + + return Response.Ok(); + }) + .WithoutWarmUp() + .WithLoadSimulations( + Simulation.IterationsForConstant(copies: 50, iterations: 1000) + + // or you can use + // Simulation.IterationsForInject(rate: 50, interval: TimeSpan.FromSeconds(1), iterations: 1000) + ); + + NBomberRunner + .RegisterScenarios(scenario) + .Run(); + } +} diff --git a/examples/Demo/Program.cs b/examples/Demo/Program.cs index 07072e9a..fd0dc411 100644 --- a/examples/Demo/Program.cs +++ b/examples/Demo/Program.cs @@ -18,7 +18,7 @@ using Demo.HTTP.SimpleBookstore; // ------------------------------- -// -----Hello World examples ----- +// ----- Hello World examples ----- // ------------------------------- new HelloWorldExample().Run(); // new ScenarioWithInit().Run(); @@ -26,10 +26,12 @@ // new StepsShareData().Run(); // new LoggerExample().Run(); +// ----- Load Simulations ----- // new ParallelScenarios().Run(); // new ScenarioInjectRate().Run(); // new ScenarioKeepConstant().Run(); // new DelayedScenarioStart().Run(); +// new ScenarioTotalIterations().Run(); // new ScenarioWithTimeout().Run(); // new ScenarioWithStepRetry().Run();