diff --git a/examples/Demo/Demo.csproj b/examples/Demo/Demo.csproj index 78e4bb85..06aabd7c 100644 --- a/examples/Demo/Demo.csproj +++ b/examples/Demo/Demo.csproj @@ -39,9 +39,9 @@ - + - + diff --git a/examples/Demo/HTTP/HttpWithTimeoutExample.cs b/examples/Demo/HTTP/HttpWithTimeoutExample.cs index d3235623..6fc32568 100644 --- a/examples/Demo/HTTP/HttpWithTimeoutExample.cs +++ b/examples/Demo/HTTP/HttpWithTimeoutExample.cs @@ -25,10 +25,7 @@ public void Run() // HttpCompletionOption: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpcompletionoption?view=net-7.0 - var clientArgs = new HttpClientArgs( - httpCompletion: HttpCompletionOption.ResponseContentRead, // or ResponseHeadersRead - cancellationToken: timeout.Token - ); + var clientArgs = HttpClientArgs.Create(cancellationToken: timeout.Token); var response = await Http.Send(httpClient, clientArgs, request); 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();