diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-11-30 10:56:11 +0100 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-07 00:38:27 +0100 |
commit | bdb1083ef54cf99c959c554b741e62943b56e2af (patch) | |
tree | 7f0f8c4317bfaaed974b4e5ffefa56acfcd94a20 /benchmark/util | |
parent | 832290a0d425aa027c279a4a96a70550a2fdfff2 (diff) | |
download | android-node-v8-bdb1083ef54cf99c959c554b741e62943b56e2af.tar.gz android-node-v8-bdb1083ef54cf99c959c554b741e62943b56e2af.tar.bz2 android-node-v8-bdb1083ef54cf99c959c554b741e62943b56e2af.zip |
benchmark: add more util inspect and format benchmarks
This adds a couple of benchmarks to check different options and code
paths.
PR-URL: https://github.com/nodejs/node/pull/30767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'benchmark/util')
-rw-r--r-- | benchmark/util/format.js | 2 | ||||
-rw-r--r-- | benchmark/util/inspect-proxy.js | 18 |
2 files changed, 15 insertions, 5 deletions
diff --git a/benchmark/util/format.js b/benchmark/util/format.js index 44e950a6ca..976e0f4e65 100644 --- a/benchmark/util/format.js +++ b/benchmark/util/format.js @@ -13,6 +13,8 @@ const inputs = { 'no-replace-2': ['foobar', 'yeah', 'mensch', 5], 'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }], 'many-%': ['replace%%%%s%%%%many%s%s%s', 'percent'], + 'object-to-string': ['foo %s bar', { toString() { return 'bla'; } }], + 'object-%s': ['foo %s bar', { a: true, b: false }], }; const bench = common.createBenchmark(main, { diff --git a/benchmark/util/inspect-proxy.js b/benchmark/util/inspect-proxy.js index dde86941ff..fd89d568ab 100644 --- a/benchmark/util/inspect-proxy.js +++ b/benchmark/util/inspect-proxy.js @@ -3,13 +3,21 @@ const util = require('util'); const common = require('../common.js'); -const bench = common.createBenchmark(main, { n: [2e4] }); +const bench = common.createBenchmark(main, { + n: [2e4], + showProxy: [0, 1], + isProxy: [0, 1] +}); -function main({ n }) { - const proxyA = new Proxy({}, { get: () => {} }); - const proxyB = new Proxy(() => {}, {}); +function main({ n, showProxy, isProxy }) { + let proxyA = {}; + let proxyB = () => {}; + if (isProxy) { + proxyA = new Proxy(proxyA, { get: () => {} }); + proxyB = new Proxy(proxyB, {}); + } bench.start(); for (let i = 0; i < n; i += 1) - util.inspect({ a: proxyA, b: proxyB }, { showProxy: true }); + util.inspect({ a: proxyA, b: proxyB }, { showProxy }); bench.end(n); } |