Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/articles/guides/how-it-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ BenchmarkDotNet follows the following steps to run your benchmarks:
2. Next, we take each method/job/params combination and try to measure its performance by launching benchmark process several times (`LaunchCount`).
3. An invocation of the workload method is an *operation*. A bunch of operation is an *iteration*. If you have an `IterationSetup` method, it will be invoked before each iteration,
but not between operations. We have the following type of iterations:
* `Jitting`: The overhead/workload methods are invoked to ensure they are JIT-compiled (and on tiered runtimes, to promote them when possible). These iterations are not used for measurements.
* `Pilot`: The best operation count will be chosen.
* `OverheadWarmup`, `OverheadWorkload`: BenchmarkDotNet overhead will be evaluated.
* `ActualWarmup`: Warmup of the workload method.
Expand Down Expand Up @@ -35,6 +36,7 @@ IEnumerable<Results> Run(Benchmark benchmark)
Result ActualRun(Method method, Job job)
{
GlobalSetup();
JittingStage(method); // triggers JIT compilation (and tiering if enabled) before Pilot/Warmup

int unrollFactor = job.Run.UnrollFactor; // 16 by default

Expand All @@ -54,6 +56,19 @@ Result ActualRun(Method method, Job job)
return (result - Median(overhead), gcStats);
}

void JittingStage(Method method)
{
RunIteration(method, invokeCount: 1, unrollFactor: 1);
if (JitInfo.IsTiered)
{
for (int i = 0; i < JitInfo.MaxTierPromotions; i++)
{
RunIteration(method, invokeCount: JitInfo.TieredCallCountThreshold, unrollFactor: 1);
Thread.Sleep(250);
}
}
}

long Pilot(Method method, int unrollFactor)
{
// invokeCount is the equivalent of InnerIterationCount from xunit-performance
Expand Down