Skip to content

Commit

Permalink
benchmark: add AbortSignal.abort benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Apr 7, 2024
1 parent 65dd60f commit 437416d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions benchmark/abort_controller/abort-signal-static-abort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [5e6],
kind: ['default-reason', 'same-reason'],
});

function main({ n, kind }) {
switch (kind) {
case 'default-reason':
bench.start();
for (let i = 0; i < n; ++i)
AbortSignal.abort();
bench.end(n);
break;
case 'same-reason':
const reason = new Error('same reason')

Check failure on line 18 in benchmark/abort_controller/abort-signal-static-abort.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Unexpected lexical declaration in case block

Check failure on line 18 in benchmark/abort_controller/abort-signal-static-abort.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon

bench.start();
for (let i = 0; i < n; ++i)
AbortSignal.abort(reason);
bench.end(n);
break;
default:
throw new Error('Invalid kind');
}
}

0 comments on commit 437416d

Please sign in to comment.