mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(node/perf_hooks): stub eventLoopUtilization (#24501)
This PR stubs `perf_hooks.eventLoopUtilization` to make the tests of [hapi](https://github.com/hapijs/hapi) start. Previously, they'd all error because of this function throwing a not implemented error. This brings down the test failures in their suite from 982 to 68 failures.
This commit is contained in:
parent
60668c1e93
commit
26288cf2a9
2 changed files with 16 additions and 4 deletions
|
@ -26,8 +26,11 @@ const performance:
|
||||||
"clearMeasures" | "getEntries"
|
"clearMeasures" | "getEntries"
|
||||||
>
|
>
|
||||||
& {
|
& {
|
||||||
// deno-lint-ignore no-explicit-any
|
eventLoopUtilization(): {
|
||||||
eventLoopUtilization: any;
|
idle: number;
|
||||||
|
active: number;
|
||||||
|
utilization: number;
|
||||||
|
};
|
||||||
nodeTiming: Record<string, string>;
|
nodeTiming: Record<string, string>;
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
timerify: any;
|
timerify: any;
|
||||||
|
@ -37,8 +40,10 @@ const performance:
|
||||||
markResourceTiming: any;
|
markResourceTiming: any;
|
||||||
} = {
|
} = {
|
||||||
clearMarks: (markName: string) => shimPerformance.clearMarks(markName),
|
clearMarks: (markName: string) => shimPerformance.clearMarks(markName),
|
||||||
eventLoopUtilization: () =>
|
eventLoopUtilization: () => {
|
||||||
notImplemented("eventLoopUtilization from performance"),
|
// TODO(@marvinhagemeister): Return actual non-stubbed values
|
||||||
|
return { idle: 0, active: 0, utilization: 0 };
|
||||||
|
},
|
||||||
mark: (markName: string) => shimPerformance.mark(markName),
|
mark: (markName: string) => shimPerformance.mark(markName),
|
||||||
measure: (
|
measure: (
|
||||||
measureName: string,
|
measureName: string,
|
||||||
|
|
|
@ -61,3 +61,10 @@ Deno.test({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test("[perf_hooks]: eventLoopUtilization", () => {
|
||||||
|
const obj = performance.eventLoopUtilization();
|
||||||
|
assertEquals(typeof obj.idle, "number");
|
||||||
|
assertEquals(typeof obj.active, "number");
|
||||||
|
assertEquals(typeof obj.utilization, "number");
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue