mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
chore(cli): measure performance against wall-clock (#18357)
Fixes test flake by requiring perf to be <150% of wall-clock time rather than <500ms.
This commit is contained in:
parent
79fb3b1f35
commit
03e236b614
1 changed files with 7 additions and 2 deletions
|
@ -81,9 +81,12 @@ Deno.test(function performanceMeasure() {
|
|||
const measureName1 = "measure1";
|
||||
const measureName2 = "measure2";
|
||||
const mark1 = performance.mark(markName1);
|
||||
// Measure against the inaccurate-but-known-good wall clock
|
||||
const now = new Date().valueOf();
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const later = new Date().valueOf();
|
||||
const measure1 = performance.measure(measureName1, markName1);
|
||||
const measure2 = performance.measure(
|
||||
measureName2,
|
||||
|
@ -103,8 +106,10 @@ Deno.test(function performanceMeasure() {
|
|||
`duration below 100ms: ${measure1.duration}`,
|
||||
);
|
||||
assert(
|
||||
measure1.duration < 500,
|
||||
`duration exceeds 500ms: ${measure1.duration}`,
|
||||
measure1.duration < (later - now) * 1.50,
|
||||
`duration exceeds 150% of wallclock time: ${measure1.duration}ms vs ${
|
||||
later - now
|
||||
}ms`,
|
||||
);
|
||||
const entries = performance.getEntries();
|
||||
assert(entries[entries.length - 1] === measure2);
|
||||
|
|
Loading…
Reference in a new issue