Skip to content

Commit 7d1b8ea

Browse files
committed
benchmark: add util.getCallSite bench
1 parent 8c114c9 commit 7d1b8ea

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

benchmark/util/get-callsite.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
const util = require('node:util');
5+
const assert = require('node:assert');
6+
7+
const bench = common.createBenchmark(main, {
8+
n: [1e6],
9+
});
10+
11+
function main({ n }) {
12+
bench.start();
13+
let lastStack = {};
14+
for (let i = 0; i < n; i++) {
15+
const stack = util.getCallSite();
16+
lastStack = stack;
17+
}
18+
bench.end(n);
19+
// Attempt to avoid dead-code elimination
20+
assert.ok(lastStack);
21+
}

0 commit comments

Comments
 (0)