From 853b7c8764046ada3f5369399722ac0048f21948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Louren=C3=A7o?= Date: Tue, 17 Oct 2023 21:26:40 -0300 Subject: [PATCH] test: avoid v8 deadcode on performance function PR-URL: https://github.com/nodejs/node/pull/50074 Reviewed-By: Stephen Belanger Reviewed-By: Matteo Collina Reviewed-By: Rafael Gonzaga Backport-PR-URL: https://github.com/nodejs/node/pull/50074 --- test/parallel/test-performance-function.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-performance-function.js b/test/parallel/test-performance-function.js index 5f774d6c2adcf5..b69a21308cf048 100644 --- a/test/parallel/test-performance-function.js +++ b/test/parallel/test-performance-function.js @@ -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 }), {