Skip to content

Commit b717db5

Browse files
committed
benchmark: calibrate util.inspect
According to nodejs/performance#186 this benchmark takes 5.14 minutes to run a single run. So using calibrate-n script it suggests reduce it from 8e4 to 1e3
1 parent 5b90eab commit b717db5

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

benchmark/util/inspect.js

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const opts = {
99
none: undefined,
1010
};
1111
const bench = common.createBenchmark(main, {
12-
n: [8e4],
12+
n: [1000],
1313
method: [
1414
'Object',
1515
'Object_empty',
@@ -47,18 +47,22 @@ function main({ method, n, option }) {
4747
benchmark(n, {}, options);
4848
break;
4949
case 'Object_deep_ln':
50-
if (options)
51-
options.depth = Infinity;
52-
obj = { first:
53-
{ second:
54-
{ third:
55-
{ a: 'first',
56-
b: 'second',
57-
c: 'third',
58-
d: 'fourth',
59-
e: 'fifth',
60-
f: 'sixth',
61-
g: 'seventh' } } } };
50+
if (options) options.depth = Infinity;
51+
obj = {
52+
first: {
53+
second: {
54+
third: {
55+
a: 'first',
56+
b: 'second',
57+
c: 'third',
58+
d: 'fourth',
59+
e: 'fifth',
60+
f: 'sixth',
61+
g: 'seventh',
62+
},
63+
},
64+
},
65+
};
6266
benchmark(n, obj, options || { depth: Infinity });
6367
break;
6468
case 'String':
@@ -81,14 +85,28 @@ function main({ method, n, option }) {
8185
benchmark(n, new Error('error'), options);
8286
break;
8387
case 'Array':
84-
benchmark(n, Array(50).fill().map((_, i) => i), options);
88+
benchmark(
89+
n,
90+
Array(50)
91+
.fill()
92+
.map((_, i) => i),
93+
options,
94+
);
8595
break;
8696
case 'TypedArray':
87-
obj = new Uint8Array(Array(50).fill().map((_, i) => i));
97+
obj = new Uint8Array(
98+
Array(50)
99+
.fill()
100+
.map((_, i) => i),
101+
);
88102
benchmark(n, obj, options);
89103
break;
90104
case 'TypedArray_extra':
91-
obj = new Uint8Array(Array(50).fill().map((_, i) => i));
105+
obj = new Uint8Array(
106+
Array(50)
107+
.fill()
108+
.map((_, i) => i),
109+
);
92110
obj.foo = 'bar';
93111
obj[Symbol('baz')] = 5;
94112
benchmark(n, obj, options);

0 commit comments

Comments
 (0)