mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
c430aebe86
This makes sure we do not retrieve the handler in case it's not required. This improves the performance a tiny bit for these cases. 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>
24 lines
509 B
JavaScript
24 lines
509 B
JavaScript
'use strict';
|
|
|
|
const util = require('util');
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1e5],
|
|
showProxy: [0, 1],
|
|
isProxy: [0, 1]
|
|
});
|
|
|
|
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 });
|
|
bench.end(n);
|
|
}
|