Skip to content

Commit

Permalink
test: avoid v8 deadcode on performance function
Browse files Browse the repository at this point in the history
PR-URL: nodejs#50074
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
  • Loading branch information
H4ad authored and alexfernandez committed Nov 1, 2023
1 parent 05ca169 commit eaf14b3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/parallel/test-performance-function.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ const {
}

(async () => {
let _deadCode;

const histogram = createHistogram();
const m = (a, b = 1) => {};
const m = (a, b = 1) => {
for (let i = 0; i < 1e3; i++)
_deadCode = i;
};
const n = performance.timerify(m, { histogram });
assert.strictEqual(histogram.max, 0);
for (let i = 0; i < 10; i++) {
n();
await sleep(10);
}
assert.ok(_deadCode >= 0);
assert.notStrictEqual(histogram.max, 0);
[1, '', {}, [], false].forEach((histogram) => {
assert.throws(() => performance.timerify(m, { histogram }), {
Expand Down

0 comments on commit eaf14b3

Please sign in to comment.