summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/net_test.ts
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2023-09-16 07:48:31 +0200
committerGitHub <noreply@github.com>2023-09-16 07:48:31 +0200
commit430b63c2c4d6567a77e77980058ef13b45a9f30e (patch)
tree714fef4813a5614ccdd17b681f30e3bd0b4057bd /cli/tests/unit_node/net_test.ts
parentbf0760411336ce5ebb1c103f766c8154af478414 (diff)
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.
Diffstat (limited to 'cli/tests/unit_node/net_test.ts')
-rw-r--r--cli/tests/unit_node/net_test.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/cli/tests/unit_node/net_test.ts b/cli/tests/unit_node/net_test.ts
index b9d9b796a..ca9d214e1 100644
--- a/cli/tests/unit_node/net_test.ts
+++ b/cli/tests/unit_node/net_test.ts
@@ -143,12 +143,17 @@ Deno.test("[node/net] multiple Sockets should get correct server data", async ()
}
const finished = deferred();
+ const serverSocketsClosed: Deferred<undefined>[] = [];
const server = net.createServer();
server.on("connection", (socket) => {
assert(socket !== undefined);
+ const i = serverSocketsClosed.push(deferred());
socket.on("data", (data) => {
socket.write(new TextDecoder().decode(data));
});
+ socket.on("close", () => {
+ serverSocketsClosed[i - 1].resolve();
+ });
});
const sockets: TestSocket[] = [];
@@ -190,6 +195,7 @@ Deno.test("[node/net] multiple Sockets should get correct server data", async ()
});
await finished;
+ await Promise.all(serverSocketsClosed);
for (let i = 0; i < socketCount; i++) {
assertEquals(sockets[i].events, [`${i}`.repeat(3), `${i}`.repeat(3)]);