| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0074790 commit 73e3c15
3 files changed
| 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, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,13 +3,21 @@ | |||
| 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 | } | |
| 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 }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments