Skip to content

Commit

Permalink
tweak integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsumners-nr committed Feb 29, 2024
1 parent 2f05822 commit 7f73309
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/integration/loop-performance.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@
const tap = require('tap')

const TEST_DURATION = 30 * 1000
let performanceThreshold = 0.98
if (process.platform === 'darwin') {
performanceThreshold = 0.95
} 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
Expand Down Expand Up @@ -42,8 +58,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)
Expand Down

0 comments on commit 7f73309

Please sign in to comment.