/*
* To run the Bencher Simply set Bencher as Startup project and run.
* Note: Run it on Release mode.
*/
![bencher-demo](https://private-user-images.githubusercontent.com/101400043/340900766-bede4256-912e-450c-8a7c-5c9b26767e78.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1NDE2NzksIm5iZiI6MTcyNDU0MTM3OSwicGF0aCI6Ii8xMDE0MDAwNDMvMzQwOTAwNzY2LWJlZGU0MjU2LTkxMmUtNDUwYy04YTdjLTVjOWIyNjc2N2U3OC5naWY_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgyNFQyMzE2MTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hZjNlY2Q3NWE5MjU5MzhmY2Q5ZWM1MzYxZDcxMzcyZjFhYjZjZTZjOGYzNTliN2NjNjMzMjFiZDhhM2YwZWRlJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.4FCbiDicAKSXjB9Drp39_rud-IT5H69RMQrRSEhzkU4)
BenchmarkDotNet v0.13.12, Windows 10
AMD Ryzen 9 5900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK 7.0.100
[Host] : .NET 7.0.16 (7.0.1624.6629), X64 RyuJIT AVX2 [AttachedDebugger]
DefaultJob : .NET 7.0.0 (7.0.22.51805), X64 RyuJIT AVX2
Method |
Mean |
Error |
StdDev |
Gen0 |
Allocated |
UsingTake |
49.71 ns |
0.428 ns |
0.401 ns |
0.0167 |
280 B |
UsingSubstring |
30.90 ns |
0.570 ns |
0.476 ns |
0.0086 |
144 B |
UsingSlice |
18.51 ns |
0.253 ns |
0.224 ns |
0.0086 |
144 B |
UsingRange |
19.38 ns |
0.409 ns |
0.546 ns |
0.0086 |
144 B |
Method |
Mean |
Error |
StdDev |
Median |
Allocated |
UsingIfAndElse |
2.5309 ns |
0.0059 ns |
0.0049 ns |
2.5308 ns |
- |
UsingSwitch |
0.0052 ns |
0.0088 ns |
0.0074 ns |
0.0015 ns |
- |
UsingSwitchExpression |
0.0016 ns |
0.0046 ns |
0.0038 ns |
0.0000 ns |
- |
ControlFlowWithGenericFunctions
Method |
Mean |
Error |
StdDev |
Allocated |
UsingIfAndElse |
31.99 ns |
0.163 ns |
0.152 ns |
- |
UsingSwitch |
110.30 ns |
0.673 ns |
0.630 ns |
- |
UsingSwitchExpression |
107.93 ns |
0.293 ns |
0.274 ns |
- |
Method |
Mean |
Error |
StdDev |
Allocated |
SimpleString |
142.9 us |
2.07 us |
1.84 us |
340 B |
Structured |
143.9 us |
2.27 us |
2.01 us |
351 B |
StringInterpolation |
144.0 us |
1.39 us |
1.30 us |
295 B |
Method |
Mean |
Error |
StdDev |
Gen0 |
Allocated |
NotUsingRef |
3.985 ns |
0.0501 ns |
0.0444 ns |
0.0014 |
24 B |
UsingRef |
4.027 ns |
0.0980 ns |
0.1048 ns |
0.0014 |
24 B |
Method |
Mean |
Error |
StdDev |
Allocated |
ExampleOneSecondAsync |
1,009.5 ms |
4.98 ms |
4.66 ms |
7.44 KB |
ExampleHalfSecondAsync |
504.3 ms |
2.99 ms |
2.79 ms |
7.44 KB |
Method |
Mean |
Error |
StdDev |
Gen0 |
Allocated |
UsingDependencyInjection |
26.26 ns |
0.136 ns |
0.121 ns |
- |
- |
NotUsingDependencyInjection |
30.36 ns |
0.434 ns |
0.385 ns |
0.0014 |
24 B |
Package: https://github.com/amantinband/error-or
Method |
Mean |
Error |
StdDev |
Gen0 |
Allocated |
UsingError_Or |
27.11 ns |
0.575 ns |
0.615 ns |
0.0110 |
184 B |
NotUsingError_Or |
4,297.04 ns |
21.195 ns |
19.826 ns |
0.0153 |
344 B |
Method |
Mean |
Error |
StdDev |
Gen0 |
Allocated |
UsingSimpleEnumToString |
12.4006 ns |
0.0977 ns |
0.0866 ns |
0.0014 |
24 B |
UsingFullyMappedNameOfEnum |
1.2797 ns |
0.0143 ns |
0.0134 ns |
- |
- |
UsingNameOfEnum |
0.6748 ns |
0.0257 ns |
0.0240 ns |
- |
- |
Method |
Mean |
Error |
StdDev |
Median |
Gen0 |
Gen1 |
Allocated |
UsingObjectDifferV1 |
3.684 us |
0.0729 us |
0.1386 us |
3.612 us |
0.6752 |
0.0038 |
11.07 KB |
UsingObjectDifferV2 |
3.107 us |
0.0513 us |
0.0549 us |
3.103 us |
0.1907 |
- |
3.13 KB |
UsingObjectDifferV3 |
2.645 us |
0.0163 us |
0.0136 us |
2.648 us |
0.2937 |
- |
4.84 KB |
Thank you for considering contributing to Bencher!
For information on contributing to this project, please see the contributing guide.