Skip to content

Commit 9de3f6f

Browse files
committed
refine test arguments and measure elapsed time in isNativeError benchmark
1 parent 5fcf423 commit 9de3f6f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

benchmark/util/is-native-error.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ function main({ argument, version, n }) {
2626

2727
const func = { native: util, js: types }[version].isNativeError;
2828

29-
const testArgs = [args[argument], args[argument], args[argument]];
30-
let sum = 0;
29+
const testArgs = [args.true, args.falsePrimitive, args.falseObject];
3130

3231
bench.start();
32+
const start = performance.now();
3333
for (let iteration = 0; iteration < n; iteration++) {
34-
const testArg = testArgs[iteration % 3];
35-
sum += func(testArg) ? 1 : 0;
34+
const testArg = testArgs[iteration % testArgs.length];
35+
func(testArg);
3636
}
37+
const end = performance.now();
3738
bench.end(n);
38-
if (sum < 0) console.log(sum);
39+
console.log('Elapsed(ms):', (end - start).toFixed(3));
3940
}

0 commit comments

Comments
 (0)