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: #50074
Backport-PR-URL: #51306
Reviewed-By: Stephen Belanger <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
  • Loading branch information
H4ad authored and RafaelGSS committed Apr 10, 2024
1 parent 72aabe1 commit 32014f5
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 32014f5

Please sign in to comment.