| 9 | }); |
| 10 | |
| 11 | function main({ n, type }) { |
| 12 | let fn; |
| 13 | if (type === 'extend') { |
| 14 | fn = util._extend; |
| 15 | } else if (type === 'assign') { |
| 16 | fn = Object.assign; |
| 17 | } |
| 18 | |
| 19 | // Force-optimize the method to test so that the benchmark doesn't |
| 20 | // get disrupted by the optimizer kicking in halfway through. |
| 21 | for (let i = 0; i < type.length * 10; i += 1) |
| 22 | fn({}, process.env); |
| 23 | |
| 24 | const obj = new Proxy({}, { set: function(a, b, c) { return true; } }); |
| 25 | |
| 26 | bench.start(); |
| 27 | for (let j = 0; j < n; j += 1) |
| 28 | fn(obj, process.env); |
| 29 | bench.end(n); |
| 30 | } |