GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — benchmark: add more util inspect and format benchmarks · nodejs/node@a1555cb

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • benchmark/util
    • format.js
    • inspect-proxy.js
  • test/benchmark
    • test-benchmark-util.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.