From 7d9ba09f5a4464072476b8992e43f5e5c30bde3a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 13 Nov 2024 19:47:01 +0530 Subject: fix(ext/node): use ERR_NOT_IMPLEMENTED for notImplemented (#26853) --- tests/unit_node/perf_hooks_test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/unit_node/perf_hooks_test.ts') diff --git a/tests/unit_node/perf_hooks_test.ts b/tests/unit_node/perf_hooks_test.ts index d5b900041..8247f9fd3 100644 --- a/tests/unit_node/perf_hooks_test.ts +++ b/tests/unit_node/perf_hooks_test.ts @@ -1,6 +1,10 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import * as perfHooks from "node:perf_hooks"; -import { performance, PerformanceObserver } from "node:perf_hooks"; +import { + monitorEventLoopDelay, + performance, + PerformanceObserver, +} from "node:perf_hooks"; import { assertEquals, assertThrows } from "@std/assert"; Deno.test({ @@ -68,3 +72,12 @@ Deno.test("[perf_hooks]: eventLoopUtilization", () => { assertEquals(typeof obj.active, "number"); assertEquals(typeof obj.utilization, "number"); }); + +Deno.test("[perf_hooks]: monitorEventLoopDelay", () => { + const e = assertThrows(() => { + monitorEventLoopDelay({ resolution: 1 }); + }); + + // deno-lint-ignore no-explicit-any + assertEquals((e as any).code, "ERR_NOT_IMPLEMENTED"); +}); -- cgit v1.2.3 From 069bc15030225393f7d05521505316066464bdbd Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Tue, 19 Nov 2024 16:49:25 +0530 Subject: feat(ext/node): perf_hooks.monitorEventLoopDelay() (#26905) Fixes https://github.com/denoland/deno/issues/20961 Depends on https://github.com/denoland/deno_core/pull/965 and https://github.com/denoland/deno_core/pull/966 --- tests/unit_node/perf_hooks_test.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'tests/unit_node/perf_hooks_test.ts') diff --git a/tests/unit_node/perf_hooks_test.ts b/tests/unit_node/perf_hooks_test.ts index 8247f9fd3..83d006222 100644 --- a/tests/unit_node/perf_hooks_test.ts +++ b/tests/unit_node/perf_hooks_test.ts @@ -5,7 +5,7 @@ import { performance, PerformanceObserver, } from "node:perf_hooks"; -import { assertEquals, assertThrows } from "@std/assert"; +import { assert, assertEquals, assertThrows } from "@std/assert"; Deno.test({ name: "[perf_hooks] performance", @@ -73,11 +73,16 @@ Deno.test("[perf_hooks]: eventLoopUtilization", () => { assertEquals(typeof obj.utilization, "number"); }); -Deno.test("[perf_hooks]: monitorEventLoopDelay", () => { - const e = assertThrows(() => { - monitorEventLoopDelay({ resolution: 1 }); - }); +Deno.test("[perf_hooks]: monitorEventLoopDelay", async () => { + const e = monitorEventLoopDelay(); + assertEquals(e.count, 0); + e.enable(); - // deno-lint-ignore no-explicit-any - assertEquals((e as any).code, "ERR_NOT_IMPLEMENTED"); + await new Promise((resolve) => setTimeout(resolve, 100)); + + assert(e.min > 0); + assert(e.minBigInt > 0n); + assert(e.count > 0); + + e.disable(); }); -- cgit v1.2.3