Skip to content
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

fix(bench): use total time when measuring wavg #20862

Merged
merged 1 commit into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 2 additions & 8 deletions cli/js/40_testing.js
Original file line number Diff line number Diff line change
Expand Up @@ -982,20 +982,17 @@ async function benchMeasure(timeBudget, fn, async, context) {
fn(context);
const t2 = benchNow();
const totalTime = t2 - t1;
let measuredTime = totalTime;
if (currentBenchUserExplicitStart !== null) {
measuredTime -= currentBenchUserExplicitStart - t1;
currentBenchUserExplicitStart = null;
usedExplicitTimers = true;
}
if (currentBenchUserExplicitEnd !== null) {
measuredTime -= t2 - currentBenchUserExplicitEnd;
currentBenchUserExplicitEnd = null;
usedExplicitTimers = true;
}

c++;
wavg += measuredTime;
wavg += totalTime;
budget -= totalTime;
}
} else {
Expand All @@ -1004,20 +1001,17 @@ async function benchMeasure(timeBudget, fn, async, context) {
await fn(context);
const t2 = benchNow();
const totalTime = t2 - t1;
let measuredTime = totalTime;
if (currentBenchUserExplicitStart !== null) {
measuredTime -= currentBenchUserExplicitStart - t1;
currentBenchUserExplicitStart = null;
usedExplicitTimers = true;
}
if (currentBenchUserExplicitEnd !== null) {
measuredTime -= t2 - currentBenchUserExplicitEnd;
currentBenchUserExplicitEnd = null;
usedExplicitTimers = true;
}

c++;
wavg += measuredTime;
wavg += totalTime;
budget -= totalTime;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ benchmark time (avg) iter/s (min … max)
----------------------------------------------------------------------------- -----------------------------
noop with start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
Warning: start() and end() calls in "noop with start and end" are ignored because it averages less
than 0.01s per iteration. Remove them for better results.
than 10µs per iteration. Remove them for better results.
2 changes: 1 addition & 1 deletion cli/tools/bench/reporters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl BenchReporter for ConsoleReporter {
);

if !stats.high_precision && stats.used_explicit_timers {
println!("{}", colors::yellow(format!("Warning: start() and end() calls in \"{}\" are ignored because it averages less\nthan 0.01s per iteration. Remove them for better results.", &desc.name)));
println!("{}", colors::yellow(format!("Warning: start() and end() calls in \"{}\" are ignored because it averages less\nthan 10µs per iteration. Remove them for better results.", &desc.name)));
}

self.group_measurements.push((desc, stats.clone()));
Expand Down