aboutsummaryrefslogtreecommitdiff
path: root/bench/snippets/native-overhead.mjs
blob: 2a8dbd6233d0ebc06362c5acacc9e960d0825ea6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { bench, run } from "mitata";

// These are no-op C++ functions that are exported to JS.
const lazy = globalThis[Symbol.for("Bun.lazy")];
const noop = lazy("noop");
const fn = noop.function;
const regular = noop.functionRegular;

bench("C++ fn regular", () => {
  regular();
});

bench("C++ fn", () => {
  fn();
});

bench("C++ getter", () => {
  return noop.getterSetter;
});

bench("C++ setter", () => {
  noop.getterSetter = 1;
});

run();