Skip to content

Commit 32014f5

Browse files
H4adRafaelGSS
authored andcommitted
test: avoid v8 deadcode on performance function
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]>
1 parent 72aabe1 commit 32014f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/parallel/test-performance-function.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,20 @@ const {
9090
}
9191

9292
(async () => {
93+
let _deadCode;
94+
9395
const histogram = createHistogram();
94-
const m = (a, b = 1) => {};
96+
const m = (a, b = 1) => {
97+
for (let i = 0; i < 1e3; i++)
98+
_deadCode = i;
99+
};
95100
const n = performance.timerify(m, { histogram });
96101
assert.strictEqual(histogram.max, 0);
97102
for (let i = 0; i < 10; i++) {
98103
n();
99104
await sleep(10);
100105
}
106+
assert.ok(_deadCode >= 0);
101107
assert.notStrictEqual(histogram.max, 0);
102108
[1, '', {}, [], false].forEach((histogram) => {
103109
assert.throws(() => performance.timerify(m, { histogram }), {

0 commit comments

Comments
 (0)