-
-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there something wrong with this result? #1167
Comments
@NMSAzulX thanks for the question! It seems that the .NET Core 2.0 version takes 0 CPU cycles in the first case and 1 CPU cycle in the second case. It's a pretty interesting situation. Could you please share the source code of your benchmark and the full BenchmarkDotNet output (you can find .log file in the |
@AndreyAkinshin Thank you very much. Here is the Source Project and Log Folder Content just like this: Example example = new Example();
var result = example.Time; Commond:
|
@NMSAzulX thanks! It seems that this benchmark should always take 0 CPU cycles with all .NET Core versions. However, sometimes we get 1 CPU cycle error (about 0.3ns). Typically, in such cases, we have problems with loop alignment (the actual performance depends on the first line address of the main benchmark loop). We are trying to resolve such problems with the help of UnrollFactor which is 16 by default. My first hypothesis: it's not enough in your case. Could you please rerun the benchmark with |
Is the code too simple to take less than 0.0001 (ns)? : ) |
@AndreyAkinshin Hello, I've uploaded the new test log. |
It seems that the problem is resolved now. Probably, we should increase the default value of the unroll factor. @adamsitnik what do you think?
Under the summary table, you have the following warnings:
The "The method duration is indistinguishable from the empty method duration" means that your method has the same duration as the following empty method (in the context of benchmarking when we call your method many times in a loop): public int Empty() => 0; |
@AndreyAkinshin Hello~ However, the result is not very stable, the last three test rankings fluctuated a little bit.
Test 3:
Can some kind of constraint be used to avoid this problem? for (int i = 0; i < length; i++)
{
var result = Empty();
} I used this way for a new round of testing. NewTest1 、 NewTest2 、 NewTest3 The result was unexpected, but it was much more stable.
That's amazing. |
It's just a random noise which always presents in measurements. If you look at the Rank column, you should see
Typically, you shouldn't write own loop because BenchmarkDotNet will generate it for you internally. |
@AndreyAkinshin I used to stare at “Mean”. Thanks. Got it. |
I'm working on such a guide but it's not easy to briefly cover all the important cases. I really want to create a good cheat sheet for BenchmarkDotNet output and include it in the documentation, but it's not ready yet. |
Okay, thank you very much. I already have the motivation to learn. |
You are most probably right. We have hit dotnet/performance#511 after update to latest BDN and from the few runs with |
I tried to do a few tests in this way(using console tools test different version), but each time I got a different ranking.
First:
Second:
Is there something wrong with this result?
The text was updated successfully, but these errors were encountered: