From 430b63c2c4d6567a77e77980058ef13b45a9f30e Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Sat, 16 Sep 2023 07:48:31 +0200 Subject: perf: improve async op santizer speed and accuracy (#20501) This commit improves async op sanitizer speed by only delaying metrics collection if there are pending ops. This results in a speedup of around 30% for small CPU bound unit tests. It performs this check and possible delay on every collection now, fixing an issue with parent test leaks into steps. --- cli/tests/testdata/test/ops_sanitizer_step_leak.out | 10 ++++++++++ cli/tests/testdata/test/ops_sanitizer_step_leak.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 cli/tests/testdata/test/ops_sanitizer_step_leak.out create mode 100644 cli/tests/testdata/test/ops_sanitizer_step_leak.ts (limited to 'cli/tests/testdata') diff --git a/cli/tests/testdata/test/ops_sanitizer_step_leak.out b/cli/tests/testdata/test/ops_sanitizer_step_leak.out new file mode 100644 index 000000000..296c5e573 --- /dev/null +++ b/cli/tests/testdata/test/ops_sanitizer_step_leak.out @@ -0,0 +1,10 @@ +Check [WILDCARD]/cli/tests/testdata/test/ops_sanitizer_step_leak.ts +running 1 test from ./cli/tests/testdata/test/ops_sanitizer_step_leak.ts +timeout ... + step ... ok [WILDCARD] +------- output ------- +done +----- output end ----- +timeout ... ok [WILDCARD] + +ok | 1 passed (1 step) | 0 failed [WILDCARD] \ No newline at end of file diff --git a/cli/tests/testdata/test/ops_sanitizer_step_leak.ts b/cli/tests/testdata/test/ops_sanitizer_step_leak.ts new file mode 100644 index 000000000..3fb9b397e --- /dev/null +++ b/cli/tests/testdata/test/ops_sanitizer_step_leak.ts @@ -0,0 +1,10 @@ +Deno.test("timeout", async (t) => { + const timer = setTimeout(() => { + console.log("timeout"); + }, 10000); + clearTimeout(timer); + await t.step("step", async () => { + await new Promise((resolve) => setTimeout(() => resolve(), 10)); + }); + console.log("done"); +}); -- cgit v1.2.3