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
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>

Backport-PR-URL: #50074
  • Loading branch information
H4ad committed Mar 25, 2024
1 parent da9eb56 commit cbae86d
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 cbae86d

Please sign in to comment.