diff options
Diffstat (limited to 'bench/ffi/plus100/add3.napi.mjs')
-rw-r--r-- | bench/ffi/plus100/add3.napi.mjs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/bench/ffi/plus100/add3.napi.mjs b/bench/ffi/plus100/add3.napi.mjs new file mode 100644 index 000000000..fd96d8eb5 --- /dev/null +++ b/bench/ffi/plus100/add3.napi.mjs @@ -0,0 +1,19 @@ +import { bench, run } from "mitata"; + +const { add3, noop } = + "Bun" in globalThis + ? require("./plus100-napi") + : (await import("module")).createRequire(import.meta.url)("./plus100-napi"); + +bench("add3(1,2,3) napi", () => { + add3(1, 2, 3); +}); +bench("noop() napi", () => { + noop(); +}); +await run({ collect: false, percentiles: true }); +console.log("\n"); + +if (add3(1, 2, 3) !== 1 + 2 + 3) { + throw new Error("plus100(1) !== 101"); +} |