-
Notifications
You must be signed in to change notification settings - Fork 4
Benchmarks
BenchmarkDotNet is used for all benchmarking done for this library. It's used extensively to make comparisons to competitors, as well as for benchmarking different approaches used in this library.
All benchmarks are reproducible and can be found in TypeId.Benchmarks project.
At the moment of writing, there are 2 more implementations of TypeId in .NET:
Benchmarks code can be found in TypeId.Benchmarks/LibraryComparison.
The following results were generated from 3e7c6f2 commit.
In this benchmark, the TypeId is generated N
times in a loop.
BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
[Host] : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
Method | Iterations | PrefixLength | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
---------------------------------- |----------- |------------- |----------:|---------:|---------:|------:|--------:|----------:|------------:|-------------:|
FastIdsBenchmark | 1000000 | 5 | 85.74 ms | 1.150 ms | 1.076 ms | 1.00 | 0.00 | - | 264 B | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 5 | 83.96 ms | 1.085 ms | 1.015 ms | 0.98 | 0.02 | - | 861 B | 3.26 |
TcKsBenchmark | 1000000 | 5 | 83.63 ms | 0.600 ms | 0.562 ms | 0.98 | 0.01 | - | 861 B | 3.26 |
CbuctokBenchmark | 1000000 | 5 | 171.26 ms | 0.231 ms | 0.193 ms | 2.00 | 0.02 | 8333.3333 | 432001693 B | 1,636,370.05 |
| | | | | | | | | | |
FastIdsBenchmark | 1000000 | 10 | 83.79 ms | 0.169 ms | 0.141 ms | 1.00 | 0.00 | - | 923 B | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 10 | 83.23 ms | 0.280 ms | 0.262 ms | 0.99 | 0.00 | - | 921 B | 1.00 |
TcKsBenchmark | 1000000 | 10 | 83.61 ms | 0.339 ms | 0.301 ms | 1.00 | 0.00 | - | 200 B | 0.22 |
CbuctokBenchmark | 1000000 | 10 | 173.07 ms | 0.242 ms | 0.202 ms | 2.07 | 0.00 | 8333.3333 | 432000213 B | 468,039.23 |
| | | | | | | | | | |
FastIdsBenchmark | 1000000 | 63 | 96.98 ms | 0.628 ms | 0.587 ms | 1.00 | 0.00 | - | 223 B | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 63 | 89.31 ms | 0.372 ms | 0.329 ms | 0.92 | 0.01 | - | 921 B | 4.13 |
TcKsBenchmark | 1000000 | 63 | 83.33 ms | 0.341 ms | 0.284 ms | 0.86 | 0.01 | - | 200 B | 0.90 |
CbuctokBenchmark | 1000000 | 63 | 170.87 ms | 0.766 ms | 0.717 ms | 1.76 | 0.01 | 8333.3333 | 432000384 B | 1,937,221.45 |
In this benchmark, the TypeId is parsed from the string representation N
times in a loop.
BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
[Host] : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
Method | Iterations | PrefixLength | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
---------------- |----------- |------------- |----------:|---------:|---------:|------:|--------:|-----------:|----------:|------------:|
FastIdsParse | 1000000 | 5 | 43.17 ms | 0.034 ms | 0.027 ms | 1.00 | 0.00 | 583.3333 | 30.52 MB | 1.00 |
FastIdsTryParse | 1000000 | 5 | 42.89 ms | 0.104 ms | 0.098 ms | 0.99 | 0.00 | 583.3333 | 30.52 MB | 1.00 |
TcKsParse | 1000000 | 5 | 68.39 ms | 0.196 ms | 0.174 ms | 1.58 | 0.00 | 3875.0000 | 190.74 MB | 6.25 |
TcKsTryParse | 1000000 | 5 | 66.67 ms | 0.250 ms | 0.234 ms | 1.54 | 0.01 | 3875.0000 | 190.73 MB | 6.25 |
CbuctokParse | 1000000 | 5 | 187.96 ms | 1.166 ms | 1.091 ms | 4.36 | 0.03 | 8666.6667 | 419.62 MB | 13.75 |
CbuctokTryParse | 1000000 | 5 | 182.00 ms | 1.166 ms | 1.033 ms | 4.21 | 0.02 | 8666.6667 | 419.62 MB | 13.75 |
| | | | | | | | | | |
FastIdsParse | 1000000 | 10 | 45.34 ms | 0.039 ms | 0.035 ms | 1.00 | 0.00 | 916.6667 | 45.78 MB | 1.00 |
FastIdsTryParse | 1000000 | 10 | 45.40 ms | 0.181 ms | 0.169 ms | 1.00 | 0.00 | 916.6667 | 45.78 MB | 1.00 |
TcKsParse | 1000000 | 10 | 84.71 ms | 0.339 ms | 0.300 ms | 1.87 | 0.01 | 4500.0000 | 221.25 MB | 4.83 |
TcKsTryParse | 1000000 | 10 | 82.67 ms | 0.633 ms | 0.592 ms | 1.82 | 0.01 | 4571.4286 | 221.25 MB | 4.83 |
CbuctokParse | 1000000 | 10 | 190.09 ms | 1.415 ms | 1.324 ms | 4.19 | 0.03 | 9000.0000 | 434.88 MB | 9.50 |
CbuctokTryParse | 1000000 | 10 | 194.78 ms | 1.539 ms | 1.440 ms | 4.30 | 0.03 | 9000.0000 | 434.88 MB | 9.50 |
| | | | | | | | | | |
FastIdsParse | 1000000 | 63 | 68.20 ms | 0.229 ms | 0.191 ms | 1.00 | 0.00 | 3000.0000 | 144.96 MB | 1.00 |
FastIdsTryParse | 1000000 | 63 | 67.20 ms | 0.097 ms | 0.086 ms | 0.99 | 0.00 | 3000.0000 | 144.96 MB | 1.00 |
TcKsParse | 1000000 | 63 | 267.00 ms | 1.110 ms | 1.038 ms | 3.91 | 0.01 | 8500.0000 | 419.62 MB | 2.89 |
TcKsTryParse | 1000000 | 63 | 260.49 ms | 1.278 ms | 1.133 ms | 3.82 | 0.02 | 8500.0000 | 419.62 MB | 2.89 |
CbuctokParse | 1000000 | 63 | 245.93 ms | 3.388 ms | 3.169 ms | 3.61 | 0.05 | 11000.0000 | 534.06 MB | 3.68 |
CbuctokTryParse | 1000000 | 63 | 252.96 ms | 1.061 ms | 0.886 ms | 3.71 | 0.02 | 11000.0000 | 534.06 MB | 3.68 |
In this benchmark, the TypeId is serialized to string N
times in a loop.
BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
[Host] : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
Method | Iterations | PrefixLength | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
----------------- |----------- |------------- |---------:|---------:|---------:|------:|--------:|----------:|----------:|----------:|------------:|
FastIdsBenchmark | 1000000 | 5 | 24.34 ms | 0.087 ms | 0.073 ms | 1.00 | 0.00 | 1750.0000 | 1750.0000 | 83.92 MB | 1.00 |
TcKsBenchmark | 1000000 | 5 | 64.77 ms | 0.099 ms | 0.093 ms | 2.66 | 0.01 | 7250.0000 | 7250.0000 | 350.95 MB | 4.18 |
CbuctokBenchmark | 1000000 | 5 | 38.45 ms | 0.115 ms | 0.107 ms | 1.58 | 0.01 | 2357.1429 | 2357.1429 | 114.44 MB | 1.36 |
| | | | | | | | | | | |
FastIdsBenchmark | 1000000 | 10 | 24.71 ms | 0.089 ms | 0.084 ms | 1.00 | 0.00 | 1906.2500 | - | 91.55 MB | 1.00 |
TcKsBenchmark | 1000000 | 10 | 82.60 ms | 0.114 ms | 0.095 ms | 3.34 | 0.01 | 7428.5714 | - | 358.58 MB | 3.92 |
CbuctokBenchmark | 1000000 | 10 | 40.51 ms | 0.796 ms | 0.745 ms | 1.64 | 0.03 | 2500.0000 | - | 122.07 MB | 1.33 |
| | | | | | | | | | | |
FastIdsBenchmark | 1000000 | 63 | 30.69 ms | 0.120 ms | 0.112 ms | 1.00 | 0.00 | 4125.0000 | 4125.0000 | 198.36 MB | 1.00 |
TcKsBenchmark | 1000000 | 63 | 89.90 ms | 0.365 ms | 0.342 ms | 2.93 | 0.02 | 9666.6667 | 9666.6667 | 465.39 MB | 2.35 |
CbuctokBenchmark | 1000000 | 63 | 76.71 ms | 1.171 ms | 1.096 ms | 2.50 | 0.04 | 4714.2857 | 4714.2857 | 228.88 MB | 1.15 |
This benchmark aims to simulate a common web-app query flow when data is retrieved from the database and returned in a JSON response. This flow involves:
- Parsing the string representation of TypeId (retrieving from DB and mapping to .NET entity)
- Serializing the TypeId instance to string (for JSON response).
BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
[Host] : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
Method | Iterations | PrefixLength | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
---------------------------------- |----------- |------------- |----------:|---------:|---------:|------:|--------:|-----------:|----------:|----------:|------------:|
FastIdsBenchmark | 1000000 | 5 | 69.52 ms | 0.182 ms | 0.162 ms | 1.00 | 0.00 | 2375.0000 | - | 114.44 MB | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 5 | 71.92 ms | 0.153 ms | 0.136 ms | 1.03 | 0.00 | 2375.0000 | - | 114.44 MB | 1.00 |
TcKsBenchmark | 1000000 | 5 | 154.00 ms | 0.673 ms | 0.597 ms | 2.22 | 0.01 | 11000.0000 | - | 541.69 MB | 4.73 |
CbuctokBenchmark | 1000000 | 5 | 220.29 ms | 0.851 ms | 0.754 ms | 3.17 | 0.01 | 11000.0000 | - | 534.06 MB | 4.67 |
| | | | | | | | | | | |
FastIdsBenchmark | 1000000 | 10 | 73.14 ms | 0.294 ms | 0.275 ms | 1.00 | 0.00 | 2857.1429 | 2857.1429 | 137.33 MB | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 10 | 75.33 ms | 0.271 ms | 0.254 ms | 1.03 | 0.00 | 2857.1429 | - | 137.33 MB | 1.00 |
TcKsBenchmark | 1000000 | 10 | 155.59 ms | 0.947 ms | 0.840 ms | 2.13 | 0.02 | 12000.0000 | - | 579.84 MB | 4.22 |
CbuctokBenchmark | 1000000 | 10 | 229.95 ms | 1.943 ms | 1.817 ms | 3.14 | 0.03 | 11333.3333 | - | 556.95 MB | 4.06 |
| | | | | | | | | | | |
FastIdsBenchmark | 1000000 | 63 | 100.77 ms | 0.301 ms | 0.282 ms | 1.00 | 0.00 | 7000.0000 | - | 343.32 MB | 1.00 |
FastIdsWithoutValidationBenchmark | 1000000 | 63 | 99.30 ms | 0.157 ms | 0.147 ms | 0.99 | 0.00 | 7166.6667 | - | 343.33 MB | 1.00 |
TcKsBenchmark | 1000000 | 63 | 336.90 ms | 0.539 ms | 0.478 ms | 3.34 | 0.01 | 18000.0000 | - | 885.01 MB | 2.58 |
CbuctokBenchmark | 1000000 | 63 | 308.67 ms | 5.995 ms | 7.362 ms | 3.08 | 0.08 | 15500.0000 | - | 762.94 MB | 2.22 |