mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -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"
|
||||
>
|
||||
& {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
eventLoopUtilization: any;
|
||||
eventLoopUtilization(): {
|
||||
idle: number;
|
||||
active: number;
|
||||
utilization: number;
|
||||
};
|
||||
nodeTiming: Record<string, string>;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
timerify: any;
|
||||
|
@ -37,8 +40,10 @@ const performance:
|
|||
markResourceTiming: any;
|
||||
} = {
|
||||
clearMarks: (markName: string) => shimPerformance.clearMarks(markName),
|
||||
eventLoopUtilization: () =>
|
||||
notImplemented("eventLoopUtilization from performance"),
|
||||
eventLoopUtilization: () => {
|
||||
// TODO(@marvinhagemeister): Return actual non-stubbed values
|
||||
return { idle: 0, active: 0, utilization: 0 };
|
||||
},
|
||||
mark: (markName: string) => shimPerformance.mark(markName),
|
||||
measure: (
|
||||
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