diff --git a/bench/async-function-vs-function.js b/bench/async-function-vs-function.js new file mode 100644 index 00000000..69d3875c --- /dev/null +++ b/bench/async-function-vs-function.js @@ -0,0 +1,32 @@ +// --max-heap-size=4000 +const { createBenchmarkSuite } = require('../common') +const assert = require('assert') + +const suite = createBenchmarkSuite('async function vs function'); + +function noop() { + return true; +} + +async function noop2() { + return true; +} + +suite + .add('function', function () { + const a = noop(); + assert.ok(a); + }) + .add('[async] - function', async function () { + const a = noop(); + assert.ok(a); + }) + .add('[async] - await function', async function () { + const a = await noop(); + assert.ok(a); + }) + .add('[async] - await async function', async function () { + const a = await noop2(); + assert.ok(a); + }) + .run({ async: false }) diff --git a/scripts/generate-run-all.mjs b/scripts/generate-run-all.mjs index 12afcff4..392e7b47 100644 --- a/scripts/generate-run-all.mjs +++ b/scripts/generate-run-all.mjs @@ -12,6 +12,10 @@ const formatJobName = name => name .slice(0, 100) const benchJobs = allBenches.map((benchFile, index, array) => { + let nodeOpts = ''; + if (benchFile === 'async-function-vs-function.js') { + nodeOpts += '--max-heap-size=4000 '; + } const jobName = formatJobName(benchFile); return ` @@ -20,6 +24,7 @@ const benchJobs = allBenches.map((benchFile, index, array) => { name: Running "${benchFile}" uses: ./.github/workflows/bench.yml with: + node-opts: ${nodeOpts} bench-file: ${benchFile} node-versions: \${{ inputs.node-versions }} `;