GeezerVison is showing github.com — benchmark: add more util inspect and format benchmarks · nodejs/node@a1555cb
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: benchmark/util/format.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,6 +13,8 @@ const inputs = { | 13 | 13 | 'no-replace-2': ['foobar', 'yeah', 'mensch', 5], | 14 | 14 | 'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }], | 15 | 15 | '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 }], | 16 | 18 | }; | 17 | 19 |
| 18 | 20 | const bench = common.createBenchmark(main, { | |
Collapse file Copy file name to clipboardExpand all lines: benchmark/util/inspect-proxy.js +13-5Lines changed: 13 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | const util = require('util'); | 4 | 4 | const common = require('../common.js'); | 5 | 5 |
| 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 | +}); | 7 | 11 |
| 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 | + } | 11 | 19 | bench.start(); | 12 | 20 | 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 }); | 14 | 22 | bench.end(n); | 15 | 23 | } |
Collapse file Copy file name to clipboardExpand all lines: test/benchmark/test-benchmark-util.js +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -14,5 +14,7 @@ runBenchmark('util', | 14 | 14 | 'size=1', | 15 | 15 | 'type=', | 16 | 16 | 'len=1', | 17 | | - 'version=native'], | | 17 | + 'version=native', | | 18 | + 'isProxy=1', | | 19 | + 'showProxy=1'], | 18 | 20 | { NODEJS_BENCHMARK_ZERO_ALLOWED: 1 }); |
|