Questions tagged [benchmarkdotnet]

BenchmarkDotNet is a powerful .NET library for measuring absolute and relative code performance.

BenchmarkDotNet is open source and available on GitHub under MIT license. It is distributed as a Nuget package.

BenchmarkDotNet executes measured method multiple times and accumulates statistics on time performance of the method, with ability to differentiate a first (warm up) execution time, which might involve JIT comilcation and sustained performance after the code is JIT'ed.

Example of report from BenchmarkDotNet, comparing performance of two alternative algorithms (in this case cryptographic hash sums) -- MD5 and SHA5:

BenchmarkDotNet=v0.9.0.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz, ProcessorCount=8
Frequency=2728067 ticks, Resolution=366.5599 ns
HostCLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT]


Type=Md5VsSha256  Mode=Throughput
 Method |      Median |    StdDev
------- |------------ |----------
    Md5 |  21.2912 us | 0.4373 us
 Sha256 | 107.4124 us | 1.8339 us
92 questions
0
votes
1 answer

How to benchmark methods from different classes that require arguments?

I want to use BenchmarkDotNet to run benchmarks on all three Run() methods of the following classes. But it's not clear what the syntax should be. class Class1 { [Benchmark] public bool Run(ref string[] columns) { // ... …
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
0
votes
0 answers

Why is in C# a nested foreach loop more performant than a SelectMany combined with a single foreach loop or a GroupBy?

Consider having these Models: public class BenchMarks{ public List Parents { get; set; } } public class Parent { public List Children { get; set; } } public class Child { public string Name { get; set; } public int…
Daniël Tulp
  • 1,745
  • 2
  • 22
  • 51
0
votes
1 answer

Combine unit test with benchmarkDotNet?

Is there a way to combine Unit Testing with BenchmarkDotNet? The idea would be that I would like to be able to write my unit tests using the AAA-pattern. However, when running it as a benchmark-test using dotnetBenchmark, I would like to be able to…
Inx51
  • 1,911
  • 3
  • 24
  • 44
0
votes
2 answers

Why do trace and debug level logs give small size "Allocated" and "Mean" result in dotnetBenchMark?

I am working on log severities with dotnet 7. I tried the test dotNetBenchMark library. I have questions about that result. As far as i know, debug and trace level logs have more info than other levels. if this true, i expect they should use more…
0
votes
0 answers

Can dotnet crank be used for CI/CD pipeline automation testing

I am pretty new to automation testing and testing. I am researching if I can use dot net crank and how to use it in my project for API's performance testing. So far, I have understood that it can be used to run benchmarks locally, on different…
Ribu
  • 101
  • 3
  • 8
0
votes
1 answer

How to do setup for microbencharks?

I'm trying to benchmark how long rotating different image resolutions takes. Each benchmark will be rotating the given Bitmap, and is therefore editing it. I want to reset this bitmap before each benchmark, so I looked into the [IterationSetup]…
Majd Odeh
  • 181
  • 1
  • 11
0
votes
1 answer

How do I get the Benchmark.NET MemoryDiagnoser to output data?

I have a Benchmark.NET project that runs my benchmarks and produces the latency output exactly how I want it but outputs no memory information. When I added the [MemoryDiagnoser] annotation to the class no data for this diagnoser gets output, it's…
ekke
  • 1,280
  • 7
  • 13
0
votes
2 answers

Nullability warning for a field instatiated in Setup, BenchmarkDotNet

The field _requestSigner2 is giving the nullability warning. It's basically instatiated in Setup(), which is the normal routine in BenchmarkDotNet but Visual Studio doesn't know that. What is the recommended way to solve that? =…
nop
  • 4,711
  • 6
  • 32
  • 93
0
votes
1 answer

Is there a way to setup each iteration of for-loop separately in benchmarks?

I'm trying to run benchmarks with different number of items on the database, for example: testing response time of an endpoint for checking if the name of the item already taken with 1 item on the database, 2, 5, 10, 20, 50, 100, 200, 500, 1000. A…
0
votes
1 answer

Persisting data between benchmarks using BenchmarkDotNet

I'm trying to benchmark two databases (different types, different locations). My select benchmarks are working fine, but I'm having trouble with my inserts, updates and deletes. I tried saving the key (GUID) I use for the insert in a class field of…
Paul Meems
  • 3,002
  • 4
  • 35
  • 66
0
votes
1 answer

Where can I find documentation for benchmarkdotnet output

In the output from BenchmarkDotNet I have the following lines: For the first benchmark WorkloadResult 100: 1 op, 614219700.00 ns, 614.2197 ms/op GC: 123 1 0 518085976 1 Threading: 2 0 1 For the second benchmark WorkloadResult 73: 1 op,…
Nafas
  • 183
  • 1
  • 9
0
votes
1 answer

NSubstitute allocates memory in benchmarking

I'm using NSubstitute to mock my DB calls for my benchmarking. For my benchmarking i'm using BenchmarkDotNet. Im getting memory allocation although there is no memory allocated in my substituted method. I need to know what causes this memory…
rerez
  • 111
  • 5
0
votes
1 answer

Benchmarkdotnet not respecting framework target net462

I have a small benchmark project that is targeting netcoreapp2 and net462. Exe netcoreapp2;net462
Thulani Chivandikwa
  • 3,402
  • 30
  • 33
0
votes
1 answer

2 different Benchmarks with 2 different environment variables

Trying to benchmark a function, drawManaged(), running under two different DLLs: drawManaged() function in C# drawManaged() calls drawNative() in native1base.dll (or other native dlls) through swig-interface which native DLL to load is…
Lydon Ch
  • 8,637
  • 20
  • 79
  • 132
0
votes
1 answer

Execute performance test using benchmarkdotnet without generation a solution(.sln) file in .netcore

I have a dotnet core project without a .sln file. I had added a benchmark test using nuget package benchmarkdotnet. But the performance result is giving error unable to find .sln file. Is there any alternative to run the benchmark without generation…
PREETI BANSAL
  • 185
  • 2
  • 12