-
-
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
UnrollFactor setting not working #1636
Comments
…ntil benchmarkdot net issue dotnet/BenchmarkDotNet#1636 is resolved.
[InvocationCount(3, 1)]
You have set the invocation count to 3 and unroll factor to 1, hence the code gets executed 3 times per iteration. This works as expected. I am not sure if I understand where the problem is? |
Hi. Perhaps I have misunderstood then. The scenario is performance testing of Array.Sort, where we pre-allocate a large array at global startup time, fill it with random (unsorted) values as part of [IterationSetup]. Thus, we want to re-run [IterationSetup] once before each [Benchmark], otherwise the benchmark is sorting already sorted data. My reading was that the Unroll=n would cause the Benchmark to run n times for each call to IterationSetup], hence I set Unroll=1, as discussed in #730. So maybe I just need to use [InvocationCount(1, 1)] ? |
I see. What you are looking for is You might find the following doc useful: https://benchmarkdotnet.org/articles/guides/how-it-works.html |
Example using 0.12.1 (runtime is .NET 5)
(noting that the second argument to InvocationCount is unrollFactor, and actually defaults to 1 - but shown here set explicitly to 1).
Output...
Also see #730
This affects some of the benchmarks in the dotnetcore repo, hence those affected benchmarks will currently be reporting potentially very misleading results. E.g. The Array.Sort() benchmarks are mostly running against already sorted arrays. See:
https://github.com/dotnet/performance/blob/master/src/benchmarks/micro/libraries/System.Collections/Sort.cs
The text was updated successfully, but these errors were encountered: