forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(runtime): short-circuit
queue_async_op
for Poll::Ready (denola…
- Loading branch information
1 parent
c0a684c
commit d2a408f
Showing
15 changed files
with
295 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | ||
const queueMicrotask = globalThis.queueMicrotask || process.nextTick; | ||
let [total, count] = typeof Deno !== "undefined" | ||
? Deno.args | ||
: [process.argv[2], process.argv[3]]; | ||
|
||
total = total ? parseInt(total, 0) : 50; | ||
count = count ? parseInt(count, 10) : 100000; | ||
|
||
async function bench(fun) { | ||
const start = Date.now(); | ||
for (let i = 0; i < count; i++) await fun(); | ||
const elapsed = Date.now() - start; | ||
const rate = Math.floor(count / (elapsed / 1000)); | ||
console.log(`time ${elapsed} ms rate ${rate}`); | ||
if (--total) queueMicrotask(() => bench(fun)); | ||
} | ||
|
||
bench(() => Deno.core.opAsync("op_void_async")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | ||
|
||
const listener = Deno.listen({ port: 4500 }); | ||
const response = new TextEncoder().encode( | ||
"HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nHello World\n", | ||
); | ||
|
||
// Accept a connection and write packets as fast as possible. | ||
async function acceptWrite() { | ||
const conn = await listener.accept(); | ||
try { | ||
while (true) { | ||
await conn.write(response); | ||
} | ||
} catch { | ||
// Pass | ||
} | ||
conn.close(); | ||
} | ||
|
||
await acceptWrite(); | ||
await acceptWrite(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[WILDCARD]error: Uncaught (in promise) BadResource: Bad resource ID | ||
[WILDCARD]error: Uncaught [WILDCARD] BadResource: Bad resource ID | ||
[WILDCARD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
error: Uncaught (in promise) RuntimeError: unreachable | ||
error: Uncaught [WILDCARD] RuntimeError: unreachable | ||
at <anonymous> (wasm:https://wasm/d1c677ea:1:41) | ||
at [WILDCARD]/wasm_unreachable.js:[WILDCARD] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.