/
ZipfianDistributionExample.cs
63 lines (59 loc) · 1.79 KB
/
ZipfianDistributionExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using MathNet.Numerics.Distributions;
using NBomber.CSharp;
namespace Demo.Features.DynamicWorkload;
public class ZipfianDistributionExample
{
public void Run()
{
var scenario = Scenario.Create("zipfian_distribution", async context =>
{
var stepNumber = Zipf.Sample(s: 1.3, n: 5, rnd: context.Random);
if (stepNumber == 1)
{
await Step.Run("step_1", context, async () =>
{
await Task.Delay(100);
return Response.Ok();
});
}
else if (stepNumber == 2)
{
await Step.Run("step_2", context, async () =>
{
await Task.Delay(100);
return Response.Ok();
});
}
else if (stepNumber == 3)
{
await Step.Run("step_3", context, async () =>
{
await Task.Delay(100);
return Response.Ok();
});
}
else if (stepNumber == 4)
{
await Step.Run("step_4", context, async () =>
{
await Task.Delay(100);
return Response.Ok();
});
}
else
{
await Step.Run("step_5", context, async () =>
{
await Task.Delay(100);
return Response.Ok();
});
}
return Response.Ok();
})
.WithoutWarmUp()
.WithLoadSimulations(Simulation.KeepConstant(copies: 1, during: TimeSpan.FromSeconds(30)));
NBomberRunner
.RegisterScenarios(scenario)
.Run();
}
}