Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1555cb

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
benchmark: add more util inspect and format benchmarks
This adds a couple of benchmarks to check different options and code paths. Backport-PR-URL: #31431 PR-URL: #30767 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent a1ce776 commit a1555cb
Copy full SHA for a1555cb

File tree

Expand file treeCollapse file tree

3 files changed

+18
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+18
-6
lines changed
Open diff view settings
Collapse file

‎benchmark/util/format.js‎

Copy file name to clipboardExpand all lines: benchmark/util/format.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const inputs = {
1313
'no-replace-2': ['foobar', 'yeah', 'mensch', 5],
1414
'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }],
1515
'many-%': ['replace%%%%s%%%%many%s%s%s', 'percent'],
16+
'object-to-string': ['foo %s bar', { toString() { return 'bla'; } }],
17+
'object-%s': ['foo %s bar', { a: true, b: false }],
1618
};
1719

1820
const bench = common.createBenchmark(main, {
Collapse file

‎benchmark/util/inspect-proxy.js‎

Copy file name to clipboardExpand all lines: benchmark/util/inspect-proxy.js
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
const util = require('util');
44
const common = require('../common.js');
55

6-
const bench = common.createBenchmark(main, { n: [2e4] });
6+
const bench = common.createBenchmark(main, {
7+
n: [2e4],
8+
showProxy: [0, 1],
9+
isProxy: [0, 1]
10+
});
711

8-
function main({ n }) {
9-
const proxyA = new Proxy({}, { get: () => {} });
10-
const proxyB = new Proxy(() => {}, {});
12+
function main({ n, showProxy, isProxy }) {
13+
let proxyA = {};
14+
let proxyB = () => {};
15+
if (isProxy) {
16+
proxyA = new Proxy(proxyA, { get: () => {} });
17+
proxyB = new Proxy(proxyB, {});
18+
}
1119
bench.start();
1220
for (let i = 0; i < n; i += 1)
13-
util.inspect({ a: proxyA, b: proxyB }, { showProxy: true });
21+
util.inspect({ a: proxyA, b: proxyB }, { showProxy });
1422
bench.end(n);
1523
}
Collapse file

‎test/benchmark/test-benchmark-util.js‎

Copy file name to clipboardExpand all lines: test/benchmark/test-benchmark-util.js
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ runBenchmark('util',
1414
'size=1',
1515
'type=',
1616
'len=1',
17-
'version=native'],
17+
'version=native',
18+
'isProxy=1',
19+
'showProxy=1'],
1820
{ NODEJS_BENCHMARK_ZERO_ALLOWED: 1 });

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.