mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
fix(bench): use total time when measuring wavg (#20862)
This commit is contained in:
parent
6450334f5b
commit
0606c11403
3 changed files with 4 additions and 10 deletions
|
@ -982,20 +982,17 @@ async function benchMeasure(timeBudget, fn, async, context) {
|
||||||
fn(context);
|
fn(context);
|
||||||
const t2 = benchNow();
|
const t2 = benchNow();
|
||||||
const totalTime = t2 - t1;
|
const totalTime = t2 - t1;
|
||||||
let measuredTime = totalTime;
|
|
||||||
if (currentBenchUserExplicitStart !== null) {
|
if (currentBenchUserExplicitStart !== null) {
|
||||||
measuredTime -= currentBenchUserExplicitStart - t1;
|
|
||||||
currentBenchUserExplicitStart = null;
|
currentBenchUserExplicitStart = null;
|
||||||
usedExplicitTimers = true;
|
usedExplicitTimers = true;
|
||||||
}
|
}
|
||||||
if (currentBenchUserExplicitEnd !== null) {
|
if (currentBenchUserExplicitEnd !== null) {
|
||||||
measuredTime -= t2 - currentBenchUserExplicitEnd;
|
|
||||||
currentBenchUserExplicitEnd = null;
|
currentBenchUserExplicitEnd = null;
|
||||||
usedExplicitTimers = true;
|
usedExplicitTimers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
wavg += measuredTime;
|
wavg += totalTime;
|
||||||
budget -= totalTime;
|
budget -= totalTime;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1004,20 +1001,17 @@ async function benchMeasure(timeBudget, fn, async, context) {
|
||||||
await fn(context);
|
await fn(context);
|
||||||
const t2 = benchNow();
|
const t2 = benchNow();
|
||||||
const totalTime = t2 - t1;
|
const totalTime = t2 - t1;
|
||||||
let measuredTime = totalTime;
|
|
||||||
if (currentBenchUserExplicitStart !== null) {
|
if (currentBenchUserExplicitStart !== null) {
|
||||||
measuredTime -= currentBenchUserExplicitStart - t1;
|
|
||||||
currentBenchUserExplicitStart = null;
|
currentBenchUserExplicitStart = null;
|
||||||
usedExplicitTimers = true;
|
usedExplicitTimers = true;
|
||||||
}
|
}
|
||||||
if (currentBenchUserExplicitEnd !== null) {
|
if (currentBenchUserExplicitEnd !== null) {
|
||||||
measuredTime -= t2 - currentBenchUserExplicitEnd;
|
|
||||||
currentBenchUserExplicitEnd = null;
|
currentBenchUserExplicitEnd = null;
|
||||||
usedExplicitTimers = true;
|
usedExplicitTimers = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
wavg += measuredTime;
|
wavg += totalTime;
|
||||||
budget -= totalTime;
|
budget -= totalTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,4 +6,4 @@ benchmark time (avg) iter/s (min … max)
|
||||||
----------------------------------------------------------------------------- -----------------------------
|
----------------------------------------------------------------------------- -----------------------------
|
||||||
noop with start and end [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
|
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
|
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.
|
||||||
|
|
|
@ -237,7 +237,7 @@ impl BenchReporter for ConsoleReporter {
|
||||||
);
|
);
|
||||||
|
|
||||||
if !stats.high_precision && stats.used_explicit_timers {
|
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()));
|
self.group_measurements.push((desc, stats.clone()));
|
||||||
|
|
Loading…
Add table
Reference in a new issue