0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/misc/util-extend-vs-object-assign.js
Bartosz Sosnowski 7587a11adc benchmark: remove forced optimization from misc
This removes all instances of %OptimizeFunctionOnNextCall from misc
benchmarks

PR-URL: https://github.com/nodejs/node/pull/9615
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-03-06 16:31:59 +01:00

33 lines
737 B
JavaScript

'use strict';
const common = require('../common.js');
const util = require('util');
const bench = common.createBenchmark(main, {
type: ['extend', 'assign'],
n: [10e4]
});
function main(conf) {
let fn;
const n = conf.n | 0;
if (conf.type === 'extend') {
fn = util._extend;
} else if (conf.type === 'assign') {
fn = Object.assign;
}
// Force-optimize the method to test so that the benchmark doesn't
// get disrupted by the optimizer kicking in halfway through.
for (var i = 0; i < conf.type.length * 10; i += 1)
fn({}, process.env);
var obj = new Proxy({}, { set: function(a, b, c) { return true; } });
bench.start();
for (var j = 0; j < n; j += 1)
fn(obj, process.env);
bench.end(n);
}