Skip to content

Commit

Permalink
feat: add async-function vs function
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelGSS committed Oct 26, 2023
1 parent aa10c0f commit 60c89a6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
32 changes: 32 additions & 0 deletions bench/async-function-vs-function.js
Original file line number Diff line number Diff line change
@@ -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 })
5 changes: 5 additions & 0 deletions scripts/generate-run-all.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 `
Expand All @@ -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 }}
`;
Expand Down

0 comments on commit 60c89a6

Please sign in to comment.