1
1
/*
2
- * Copyright 2020 New Relic Corporation. All rights reserved.
2
+ * Copyright 2024 New Relic Corporation. All rights reserved.
3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
6
'use strict'
7
7
8
- const tap = require ( 'tap' )
8
+ const test = require ( 'node:test' )
9
+ const assert = require ( 'node:assert' )
9
10
10
- const TEST_DURATION = 30 * 1000
11
+ const TEST_DURATION = 30 * 1_000
11
12
let performanceThreshold = 0.98
12
13
if ( process . platform === 'darwin' ) {
13
14
// The GitHub macOS runners are slow and vary widely in their slowness
@@ -17,7 +18,7 @@ if (process.platform === 'darwin') {
17
18
performanceThreshold = 0.97
18
19
}
19
20
20
- tap . test ( 'loop performance test' , { timeout : 2 * TEST_DURATION + 1000 } , function ( t ) {
21
+ test ( 'loop performance test' , { timeout : 2 * TEST_DURATION + 1_000 } , ( t , end ) => {
21
22
// The purpose of this test is to measure how much tracking metrics
22
23
// impacts the processing overhead of the application loop. To do so, we:
23
24
//
@@ -32,13 +33,13 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
32
33
let callCount = 0
33
34
let natives = null
34
35
35
- t . teardown ( function ( ) {
36
+ t . after ( function ( ) {
36
37
if ( natives ) {
37
38
natives . unbind ( )
38
39
}
39
40
} )
40
41
41
- t . comment ( ' measuring without loop counter' )
42
+ // measuring without loop counter
42
43
setTimeoutCount ( )
43
44
setTimeout ( function ( ) {
44
45
const noMetricsCount = callCount
@@ -48,22 +49,22 @@ tap.test('loop performance test', { timeout: 2 * TEST_DURATION + 1000 }, functio
48
49
natives = require ( '../../' ) ( )
49
50
const readInterval = setInterval ( function ( ) {
50
51
natives . getLoopMetrics ( ) // To reset the metrics
51
- } , 1000 )
52
+ } , 1_000 )
52
53
53
- t . comment ( ' measuring with loop counter' )
54
+ // measuring with loop counter
54
55
setTimeoutCount ( )
55
56
setTimeout ( function ( ) {
56
57
const withMetricsCount = callCount
57
58
callCount = 0
58
59
clearTimeout ( timeout )
59
60
clearInterval ( readInterval )
60
61
61
- t . comment ( noMetricsCount + ' vs ' + withMetricsCount )
62
- t . ok (
62
+ // console.log (noMetricsCount + ' vs ' + withMetricsCount)
63
+ assert . ok (
63
64
noMetricsCount * performanceThreshold < withMetricsCount ,
64
65
`should not impact performance by more than ${ 1 - performanceThreshold } %`
65
66
)
66
- t . end ( )
67
+ end ( )
67
68
} , TEST_DURATION )
68
69
} , TEST_DURATION )
69
70
0 commit comments