2016-04-29 01:06:48 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const util = require('util');
|
|
|
|
const common = require('../common.js');
|
|
|
|
|
2019-11-30 10:56:11 +01:00
|
|
|
const bench = common.createBenchmark(main, {
|
2019-11-30 11:04:34 +01:00
|
|
|
n: [1e5],
|
2019-11-30 10:56:11 +01:00
|
|
|
showProxy: [0, 1],
|
2023-02-03 11:42:25 +01:00
|
|
|
isProxy: [0, 1],
|
2019-11-30 10:56:11 +01:00
|
|
|
});
|
2016-04-29 01:06:48 -07:00
|
|
|
|
2019-11-30 10:56:11 +01:00
|
|
|
function main({ n, showProxy, isProxy }) {
|
|
|
|
let proxyA = {};
|
|
|
|
let proxyB = () => {};
|
|
|
|
if (isProxy) {
|
|
|
|
proxyA = new Proxy(proxyA, { get: () => {} });
|
|
|
|
proxyB = new Proxy(proxyB, {});
|
|
|
|
}
|
2016-04-29 01:06:48 -07:00
|
|
|
bench.start();
|
2019-07-24 17:24:57 -05:00
|
|
|
for (let i = 0; i < n; i += 1)
|
2019-11-30 10:56:11 +01:00
|
|
|
util.inspect({ a: proxyA, b: proxyB }, { showProxy });
|
2016-04-29 01:06:48 -07:00
|
|
|
bench.end(n);
|
|
|
|
}
|