diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts index 3211bb4151..accedd2e42 100644 --- a/cli/tests/unit/performance_test.ts +++ b/cli/tests/unit/performance_test.ts @@ -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);