From 5276a1e368c587f581add50c816a3470f6e7f417 Mon Sep 17 00:00:00 2001 From: James Sumners Date: Thu, 29 Feb 2024 09:33:18 -0500 Subject: [PATCH] tweak integration test --- tests/integration/loop-performance.tap.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/integration/loop-performance.tap.js b/tests/integration/loop-performance.tap.js index 455c49c..0b6e731 100644 --- a/tests/integration/loop-performance.tap.js +++ b/tests/integration/loop-performance.tap.js @@ -8,8 +8,26 @@ const tap = require('tap') const TEST_DURATION = 30 * 1000 +let performanceThreshold = 0.98 +if (process.platform === 'darwin') { + // The GitHub macOS runners are slow and vary widely in their slowness + // from run to run. + performanceThreshold = 0.9 +} else if (process.platform === 'win32') { + performanceThreshold = 0.97 +} tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, function (t) { + // The purpose of this test is to measure how much tracking metrics + // impacts the processing overhead of the application loop. To do so, we: + // + // 1. Count how many times the loop fires without the native metrics + // hooks attached over a predetermined interval (TEST_DURATION). + // 2. Count how many times the loop fires with the native metrics hooks + // attached, and exercise the metrics by resetting them every 1 second + // over the test duration, again over the same predetermined interval. + // 3. Calculate the percentage overhead and assert it meets requirements. + let timeout = null let callCount = 0 let natives = null @@ -42,8 +60,8 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio t.comment(noMetricsCount + ' vs ' + withMetricsCount) t.ok( - noMetricsCount * 0.98 < withMetricsCount, - 'should not impact performance by more than 2%' + noMetricsCount * performanceThreshold < withMetricsCount, + `should not impact performance by more than ${1 - performanceThreshold}%` ) t.end() }, TEST_DURATION)