From da7fa9f8c3fd6bd408af23ee70a2f30cda15a11d Mon Sep 17 00:00:00 2001 From: Harshbhargav45 Date: Sat, 28 Nov 2026 22:53:47 +0530 Subject: [PATCH] bench: add call opcode microbenchmarks --- benches/scripts/calls/call_arrow.js | 11 +++++++++++ benches/scripts/calls/call_construct.js | 12 ++++++++++++ benches/scripts/calls/call_simple.js | 14 ++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 benches/scripts/calls/call_arrow.js create mode 100644 benches/scripts/calls/call_construct.js create mode 100644 benches/scripts/calls/call_simple.js diff --git a/benches/scripts/calls/call_arrow.js b/benches/scripts/calls/call_arrow.js new file mode 100644 index 00000000000..62f10c19230 --- /dev/null +++ b/benches/scripts/calls/call_arrow.js @@ -0,0 +1,11 @@ +// Keep the function body minimal so repeated calls dominate the benchmark. +const iterationCount = 10_000; +const identity = (value) => value; + +function main() { + let result = 0; + for (let i = 0; i < iterationCount; i++) { + result += identity(i); + } + return result; +} diff --git a/benches/scripts/calls/call_construct.js b/benches/scripts/calls/call_construct.js new file mode 100644 index 00000000000..87775017c1b --- /dev/null +++ b/benches/scripts/calls/call_construct.js @@ -0,0 +1,12 @@ +// Repeated construction isolates the constructor call path. +const iterationCount = 10_000; + +function Empty() {} + +function main() { + let instance; + for (let i = 0; i < iterationCount; i++) { + instance = new Empty(); + } + return instance; +} diff --git a/benches/scripts/calls/call_simple.js b/benches/scripts/calls/call_simple.js new file mode 100644 index 00000000000..ae2b57aada8 --- /dev/null +++ b/benches/scripts/calls/call_simple.js @@ -0,0 +1,14 @@ +// Keep the function body minimal so repeated calls dominate the benchmark. +const iterationCount = 10_000; + +function identity(value) { + return value; +} + +function main() { + let result = 0; + for (let i = 0; i < iterationCount; i++) { + result += identity(i); + } + return result; +}