aboutsummaryrefslogtreecommitdiff
path: root/bench/ffi/deno.js
diff options
context:
space:
mode:
authorGravatar evan <github@evan.lol> 2022-07-12 04:40:12 -0400
committerGravatar GitHub <noreply@github.com> 2022-07-12 01:40:12 -0700
commita9e4ff2029a769737982fcf7e0b7d76d35cf35e4 (patch)
tree497832408d926e2bed779fcec4ba655624a29792 /bench/ffi/deno.js
parent7eea306b0ff46a27f134809a9b3c12bf4b38fa7e (diff)
downloadbun-a9e4ff2029a769737982fcf7e0b7d76d35cf35e4.tar.gz
bun-a9e4ff2029a769737982fcf7e0b7d76d35cf35e4.tar.zst
bun-a9e4ff2029a769737982fcf7e0b7d76d35cf35e4.zip
cleanup benchmarks folder (#587)
* cleanup benchmarks * run prettier
Diffstat (limited to 'bench/ffi/deno.js')
-rw-r--r--bench/ffi/deno.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/bench/ffi/deno.js b/bench/ffi/deno.js
new file mode 100644
index 000000000..ee6206108
--- /dev/null
+++ b/bench/ffi/deno.js
@@ -0,0 +1,27 @@
+import { run, bench, group } from "../node_modules/mitata/src/cli.mjs";
+
+const extension = "darwin" !== Deno.build.os ? "so" : "dylib";
+const path = new URL(
+ "src/target/release/libffi_napi_bench." + extension,
+ import.meta.url
+).pathname;
+
+const {
+ symbols: { ffi_noop, ffi_hash, ffi_string },
+} = Deno.dlopen(path, {
+ ffi_noop: { parameters: [], result: "void" },
+ ffi_string: { parameters: [], result: "pointer" },
+ ffi_hash: { parameters: ["pointer", "usize"], result: "u32" },
+});
+
+const bytes = new Uint8Array(64);
+
+group("deno:ffi", () => {
+ bench("noop", () => ffi_noop());
+ bench("hash", () => ffi_hash(bytes, bytes.byteLength));
+ bench("c string", () =>
+ new Deno.UnsafePointerView(ffi_string()).getCString()
+ );
+});
+
+await run();