Skip to content

Commit 3b84571

Browse files
committed
Update benchmarks
1 parent 4a7ab18 commit 3b84571

File tree

3 files changed

+51
-18
lines changed

3 files changed

+51
-18
lines changed

README.md

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,52 @@ Sources:
1919

2020
### Initial benchmarks
2121

22-
The below benchmark is generating 100_000 and 1_000_000 `double`s per run.
22+
The benchmarks measure generation of `double`s.
23+
Iterations = `double`s per op.
24+
25+
#### With hardware counters
26+
27+
``` ini
28+
29+
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1555/22H2/2022Update/SunValley2)
30+
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
31+
.NET SDK=7.0.300-preview.23122.5
32+
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
33+
DefaultJob : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
34+
35+
36+
```
37+
| Method | Iterations | Mean | Error | StdDev | Ratio | RatioSD | Rank | BranchInstructions/Op | CacheMisses/Op | TotalCycles/Op | BranchMispredictions/Op | Allocated | Alloc Ratio |
38+
|-------------------- |----------- |---------:|--------:|--------:|-------------:|--------:|-----:|----------------------:|---------------:|---------------:|------------------------:|----------:|------------:|
39+
| SystemRandomGen | 100000 | 423.5 μs | 7.62 μs | 7.13 μs | baseline | | 4 | 603,262 | 482 | 1,293,860 | 716 | - | NA |
40+
| Xoroshiro128PlusGen | 100000 | 305.8 μs | 2.99 μs | 2.80 μs | 1.38x faster | 0.03x | 3 | 107,806 | 261 | 999,642 | 392 | - | NA |
41+
| Xoshiro256PlusGen | 100000 | 231.2 μs | 2.85 μs | 2.67 μs | 1.83x faster | 0.03x | 2 | 105,846 | 219 | 750,974 | 308 | - | NA |
42+
| ShishuaGen | 100000 | 185.7 μs | 1.32 μs | 1.24 μs | 2.28x faster | 0.05x | 1 | 437,648 | 640 | 529,914 | 346 | - | NA |
43+
44+
45+
#### Scaling iterations
46+
47+
There is likely overhead in capturing hardware counters, so these should be more "correct"
2348

2449
``` ini
2550

26-
BenchmarkDotNet=v0.13.5, OS=ubuntu 22.04
51+
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.22621.1555/22H2/2022Update/SunValley2)
2752
AMD Ryzen 5 5600X, 1 CPU, 12 logical and 6 physical cores
28-
.NET SDK=7.0.201
29-
[Host] : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
30-
DefaultJob : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
53+
.NET SDK=7.0.300-preview.23122.5
54+
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
55+
DefaultJob : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
3156

3257

3358
```
34-
| Method | Iterations | Mean | Error | StdDev | Ratio | RatioSD | Rank | Allocated | Alloc Ratio |
35-
|-------------------- |----------- |-----------:|--------:|--------:|-------------:|--------:|-----:|----------:|------------:|
36-
| SystemRandomGen | 100000 | 284.0 μs | 0.62 μs | 0.55 μs | baseline | | 4 | - | NA |
37-
| Xoroshiro128PlusGen | 100000 | 203.2 μs | 0.38 μs | 0.33 μs | 1.40x faster | 0.00x | 3 | - | NA |
38-
| Xoshiro256PlusGen | 100000 | 159.6 μs | 0.30 μs | 0.28 μs | 1.78x faster | 0.00x | 2 | - | NA |
39-
| ShishuaGen | 100000 | 104.2 μs | 0.63 μs | 0.59 μs | 2.73x faster | 0.02x | 1 | - | NA |
40-
| | | | | | | | | | |
41-
| SystemRandomGen | 1000000 | 2,847.6 μs | 3.27 μs | 2.90 μs | baseline | | 4 | 4 B | |
42-
| Xoroshiro128PlusGen | 1000000 | 2,039.1 μs | 6.19 μs | 5.79 μs | 1.40x faster | 0.00x | 3 | 4 B | 1.00x more |
43-
| Xoshiro256PlusGen | 1000000 | 1,601.5 μs | 2.78 μs | 2.60 μs | 1.78x faster | 0.00x | 2 | 2 B | 2.00x less |
44-
| ShishuaGen | 1000000 | 1,039.5 μs | 2.16 μs | 2.02 μs | 2.74x faster | 0.01x | 1 | 2 B | 2.00x less |
59+
| Method | Iterations | Mean | Error | StdDev | Ratio | RatioSD | Rank |
60+
|-------------------- |----------- |-----------:|---------:|---------:|-------------:|--------:|-----:|
61+
| SystemRandomGen | 100000 | 282.1 μs | 2.04 μs | 1.70 μs | baseline | | 4 |
62+
| Xoroshiro128PlusGen | 100000 | 213.2 μs | 0.45 μs | 0.37 μs | 1.32x faster | 0.01x | 3 |
63+
| Xoshiro256PlusGen | 100000 | 158.7 μs | 1.18 μs | 1.11 μs | 1.78x faster | 0.02x | 2 |
64+
| ShishuaGen | 100000 | 103.5 μs | 0.54 μs | 0.45 μs | 2.73x faster | 0.02x | 1 |
65+
| | | | | | | | |
66+
| SystemRandomGen | 1000000 | 2,825.6 μs | 18.07 μs | 16.90 μs | baseline | | 4 |
67+
| Xoroshiro128PlusGen | 1000000 | 2,141.1 μs | 15.47 μs | 14.47 μs | 1.32x faster | 0.01x | 3 |
68+
| Xoshiro256PlusGen | 1000000 | 1,583.3 μs | 7.22 μs | 6.40 μs | 1.79x faster | 0.01x | 2 |
69+
| ShishuaGen | 1000000 | 1,030.8 μs | 8.83 μs | 8.26 μs | 2.74x faster | 0.03x | 1 |
70+

benchmark/Fast.PRNGs.Benchmarks/Fast.PRNGs.Benchmarks.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<ItemGroup>
2424
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
2525
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.5" />
26+
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.1" />
2627
</ItemGroup>
2728
<ItemGroup>
2829
<ProjectReference Include="..\..\src\Fast.PRNGs\Fast.PRNGs.csproj" />

benchmark/Fast.PRNGs.Benchmarks/PRNGs.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class PRNGs
88
private Xoroshiro128Plus _xoroshiro128plus;
99
private Xoshiro256Plus _xoshiro256plus;
1010

11-
[Params(100_000)]
11+
[Params(100_000, 1_000_000)]
1212
public int Iterations { get; set; }
1313

1414
[GlobalSetup]
@@ -67,9 +67,15 @@ private sealed class Config : ManualConfig
6767
public Config()
6868
{
6969
this.SummaryStyle = SummaryStyle.Default.WithRatioStyle(RatioStyle.Trend);
70-
this.AddDiagnoser(MemoryDiagnoser.Default);
70+
//this.AddDiagnoser(MemoryDiagnoser.Default);
7171
this.AddColumn(RankColumn.Arabic);
7272
this.Orderer = new DefaultOrderer(SummaryOrderPolicy.SlowestToFastest, MethodOrderPolicy.Declared);
73+
//this.AddHardwareCounters(
74+
// HardwareCounter.BranchInstructions,
75+
// HardwareCounter.BranchMispredictions,
76+
// HardwareCounter.CacheMisses,
77+
// HardwareCounter.TotalCycles
78+
//);
7379
}
7480
}
7581
}

0 commit comments

Comments
 (0)