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:
Matt Mastracci 2023-03-22 12:06:29 -06:00 committed by GitHub
parent 79fb3b1f35
commit 03e236b614
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);