Skip to content

Commit 69ca552

Browse files
committed
test: fix node:bench test timing
Signed-off-by: James M Snell <jasnell@gmail.com>
1 parent 8818af1 commit 69ca552

18 files changed

Lines changed: 18 additions & 54 deletions

test/fixtures/bench-runner/a.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ bench('alpha', {
66
params: { file: 'a', pid: process.pid },
77
samples: 1,
88
}, (b) => {
9-
b.start();
10-
process.hrtime.bigint();
11-
b.end(1);
9+
b.record({ duration_ns: 1n, operations: 1 });
1210
});

test/fixtures/bench-runner/abrupt-exit.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ if (mode === 'late') {
1212
}
1313

1414
bench('abrupt exit', { samples: 1 }, (b) => {
15-
b.start();
16-
process.hrtime.bigint();
17-
b.end(1);
15+
b.record({ duration_ns: 1n, operations: 1 });
1816
});

test/fixtures/bench-runner/b.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ bench('beta', {
44
params: { file: 'b', pid: process.pid },
55
samples: 1,
66
}, (b) => {
7-
b.start();
8-
process.hrtime.bigint();
9-
b.end(1);
7+
b.record({ duration_ns: 1n, operations: 1 });
108
});

test/fixtures/bench-runner/exit-code.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
const { bench } = require('node:bench');
44

55
bench('sets exit code', { samples: 1 }, (b) => {
6-
b.start();
7-
process.hrtime.bigint();
8-
b.end(1);
6+
b.record({ duration_ns: 1n, operations: 1 });
97
process.exitCode = 2;
108
});

test/fixtures/bench-runner/imported.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ bench('imported', {
66
samples: 1,
77
params: { imported: globalThis.benchImport },
88
}, (b) => {
9-
b.start();
10-
process.hrtime.bigint();
11-
b.end(1);
9+
b.record({ duration_ns: 1n, operations: 1 });
1210
});

test/fixtures/bench-runner/inspector.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@ bench('inspector option', {
99
params: { inspectPort },
1010
samples: 1,
1111
}, (b) => {
12-
b.start();
13-
process.hrtime.bigint();
14-
b.end(1);
12+
b.record({ duration_ns: 1n, operations: 1 });
1513
});

test/fixtures/bench-runner/ipc.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ const { bench } = require('node:bench');
55
process.send?.({ type: 'user-message' });
66

77
bench('user IPC', { samples: 1 }, (b) => {
8-
b.start();
9-
process.hrtime.bigint();
10-
b.end(1);
8+
b.record({ duration_ns: 1n, operations: 1 });
119
});

test/fixtures/bench-runner/many-records.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ const { bench } = require('node:bench');
44

55
bench('many records', { samples: 30 }, (b) => {
66
process.stdout.write(`${b.index}\n`);
7-
b.start();
8-
process.hrtime.bigint();
9-
b.end(1);
7+
b.record({ duration_ns: 1n, operations: 1 });
108
});

test/fixtures/bench-runner/options.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ bench('selected', {
99
warmup: 8,
1010
}, (b) => {
1111
invocations++;
12-
b.start();
13-
process.hrtime.bigint();
14-
b.end(invocations);
12+
b.record({ duration_ns: 1n, operations: invocations });
1513
});
1614

1715
bench('filtered out', { samples: 1 }, () => {

test/fixtures/bench-runner/output.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,5 @@ process.stdout.write('benchmark stdout\n');
66
process.stderr.write('benchmark stderr\n');
77

88
bench('output', { samples: 1 }, (b) => {
9-
b.start();
10-
process.hrtime.bigint();
11-
b.end(1);
9+
b.record({ duration_ns: 1n, operations: 1 });
1210
});

0 commit comments

Comments
 (0)