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 <admin@stephenbelanger.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
  • Loading branch information
H4ad authored and richardlau committed Mar 28, 2024
1 parent 1daccf5 commit 5ff73f3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/parallel/test-performance-function.js
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 5ff73f3

Please sign in to comment.