diff options
author | 2022-05-11 15:12:17 -0700 | |
---|---|---|
committer | 2022-05-11 15:12:17 -0700 | |
commit | 61b2821472f96453e689f91cce42baa24007407d (patch) | |
tree | 2ff69914ea2365cbbf71f610c64a5cfcb94d061e | |
parent | 1f86e0c87ebeb4543f1f34fb034ef6b83c7b1e6c (diff) | |
download | bun-61b2821472f96453e689f91cce42baa24007407d.tar.gz bun-61b2821472f96453e689f91cce42baa24007407d.tar.zst bun-61b2821472f96453e689f91cce42baa24007407d.zip |
Make the napi mjs file runnable in both bun & node
-rw-r--r-- | bench/ffi/plus100/plus100.napi.mjs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bench/ffi/plus100/plus100.napi.mjs b/bench/ffi/plus100/plus100.napi.mjs index 2b3015933..65ca85ca6 100644 --- a/bench/ffi/plus100/plus100.napi.mjs +++ b/bench/ffi/plus100/plus100.napi.mjs @@ -1,15 +1,14 @@ import { bench, run } from "mitata"; -import module from "module"; +const { plus100, noop } = + "Bun" in globalThis + ? require("./plus100-napi") + : (await import("module")).createRequire(import.meta.url)("./plus100-napi"); -const { plus100, noop } = module.createRequire(import.meta.url)( - "./plus100-napi" -); - -bench("plus100(1) ", () => { +bench("plus100(1) napi", () => { plus100(1); }); -bench("noop() ", () => { +bench("noop() napi", () => { noop(); }); await run({ collect: false, percentiles: true }); |