summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-10-10 16:36:55 +0200
committerGitHub <noreply@github.com>2021-10-10 16:36:55 +0200
commitf2ac7ff23a2ae4925f4ca32ffd61c923c481ef4e (patch)
tree9d66aefc305594becd1e6c516131fd7a3c4a95f3
parent5edd2771619ddc3cd2f6c76cc93ee64277aa17c2 (diff)
bench(deno_common): track void ops (#12389)
To track overhead through the entire CLI opcall stack (metrics included, etc...)
-rw-r--r--cli/bench/deno_common.js27
-rw-r--r--core/ops_builtin.rs4
2 files changed, 31 insertions, 0 deletions
diff --git a/cli/bench/deno_common.js b/cli/bench/deno_common.js
index cc54b1036..73a2f62c5 100644
--- a/cli/bench/deno_common.js
+++ b/cli/bench/deno_common.js
@@ -18,6 +18,17 @@ async function benchAsync(name, n, innerLoop) {
console.log(benchStats(name, n, t1, t2));
}
+// Parallel version benchAsync
+async function benchAsyncP(name, n, p, innerLoop) {
+ const range = new Array(p).fill(null);
+ const t1 = Date.now();
+ for (let i = 0; i < n / p; i++) {
+ await Promise.all(range.map(() => innerLoop()));
+ }
+ const t2 = Date.now();
+ console.log(benchStats(name, n, t1, t2));
+}
+
function benchStats(name, n, t1, t2) {
const dt = (t2 - t1) / 1e3;
const r = n / dt;
@@ -75,9 +86,25 @@ function benchRequestNew() {
return benchSync("request_new", 5e5, () => new Request("https://deno.land"));
}
+function benchOpVoidSync() {
+ return benchSync("op_void_sync", 1e7, () => Deno.core.opSync("op_void_sync"));
+}
+
+function benchOpVoidAsync() {
+ return benchAsyncP(
+ "op_void_async",
+ 1e6,
+ 1e3,
+ () => Deno.core.opAsync("op_void_async"),
+ );
+}
+
async function main() {
// v8 builtin that's close to the upper bound non-NOPs
benchDateNow();
+ // Void ops measure op-overhead
+ benchOpVoidSync();
+ await benchOpVoidAsync();
// A very lightweight op, that should be highly optimizable
benchPerfNow();
// A common "language feature", that should be fast
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs
index bb04cddf4..83f2e504a 100644
--- a/core/ops_builtin.rs
+++ b/core/ops_builtin.rs
@@ -3,6 +3,8 @@ use crate::error::AnyError;
use crate::include_js_files;
use crate::op_sync;
use crate::resources::ResourceId;
+use crate::void_op_async;
+use crate::void_op_sync;
use crate::Extension;
use crate::OpState;
use crate::Resource;
@@ -30,6 +32,8 @@ pub(crate) fn init_builtins() -> Extension {
"op_wasm_streaming_set_url",
op_sync(op_wasm_streaming_set_url),
),
+ ("op_void_sync", void_op_sync()),
+ ("op_void_async", void_op_async()),
])
.build()
}