-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
73 lines (68 loc) · 2.67 KB
/
Copy pathProgram.cs
File metadata and controls
73 lines (68 loc) · 2.67 KB
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
64
65
66
67
68
69
70
71
72
73
using BenchmarkDotNet.Running;
using SharedMemoryStore.Benchmarks;
if (args.Length == 2
&& string.Equals(args[0], "--validation", StringComparison.Ordinal)
&& string.Equals(args[1], "sustained-throughput", StringComparison.Ordinal))
{
var simple = RunSimplePublishSustained();
var direct = RunDirectIngestSustained();
var relativeRatio = direct.FramesPerSecond / Math.Max(simple.PublishesPerSecond, 0.001);
var relativePercent = (relativeRatio - 1) * 100;
Console.WriteLine(BenchmarkEnvironment.Summary);
Console.WriteLine($"Simple publish: {simple.PublishesPerSecond:N2} publishes/s; frames={simple.PublishCount:N0}; status={simple.FinalStatus}; passed={simple.Passed}");
Console.WriteLine($"Direct ingest: {direct.FramesPerSecond:N2} frames/s; frames={direct.FrameCount:N0}; status={direct.FinalStatus}; passed={direct.Passed}");
Console.WriteLine($"Direct ingest relative to simple publish: {relativeRatio:N3}x ({relativePercent:N1}%).");
return;
}
if (args.Length == 2
&& string.Equals(args[0], "--validation", StringComparison.Ordinal)
&& string.Equals(args[1], "direct-allocation", StringComparison.Ordinal))
{
var result = RunDirectIngestAllocationValidation();
Console.WriteLine(BenchmarkEnvironment.Summary);
Console.WriteLine($"Direct allocation: frames={result.FrameCount:N0}; totalAllocatedBytes={result.TotalAllocatedBytes:N0}; allocatedBytesPerFrame={result.AllocatedBytesPerFrame:N3}; status={result.FinalStatus}; passed={result.Passed}");
return;
}
// Assembly discovery intentionally includes LockFreeBenchmarks alongside
// the existing reliability suites; use --filter *LockFreeBenchmarks* for
// the absolute SMS2 allocation/collision/recovery measurements.
BenchmarkSwitcher.FromAssembly(typeof(LockFreeBenchmarks).Assembly).Run(args);
static FrameThroughputValidationResult RunSimplePublishSustained()
{
var benchmark = new FrameThroughputBenchmarks();
benchmark.Setup();
try
{
return benchmark.SustainedFramePublishRemoveForSixtySeconds();
}
finally
{
benchmark.Cleanup();
}
}
static DirectIngestThroughputValidationResult RunDirectIngestSustained()
{
var benchmark = new DirectIngestFrameThroughputBenchmarks();
benchmark.Setup();
try
{
return benchmark.SustainedDirectIngestForSixtySeconds();
}
finally
{
benchmark.Cleanup();
}
}
static DirectIngestAllocationValidationResult RunDirectIngestAllocationValidation()
{
var benchmark = new DirectIngestAllocationBenchmarks();
benchmark.Setup();
try
{
return benchmark.ValidateOneHundredThousandFramesAllocation();
}
finally
{
benchmark.Cleanup();
}
}