We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 55a3fbc commit f8ad300Copy full SHA for f8ad300
benchmark/abort_controller/abort-signal-static-abort.js
@@ -0,0 +1,29 @@
1
+'use strict';
2
+const common = require('../common.js');
3
+
4
+const bench = common.createBenchmark(main, {
5
+ n: [5e6],
6
+ kind: ['default-reason', 'same-reason'],
7
+});
8
9
+function main({ n, kind }) {
10
+ switch (kind) {
11
+ case 'default-reason':
12
+ bench.start();
13
+ for (let i = 0; i < n; ++i)
14
+ AbortSignal.abort();
15
+ bench.end(n);
16
+ break;
17
+ case 'same-reason': {
18
+ const reason = new Error('same reason');
19
20
21
22
+ AbortSignal.abort(reason);
23
24
25
+ }
26
+ default:
27
+ throw new Error('Invalid kind');
28
29
+}
0 commit comments