Browse Source

benchmark: use node v4 syntax in common.js

Using new syntax such as `...args` means that the benchmark suite can't
be used with older node versions. This changes the `...args` syntax to a
good old `Array.prototype.slice`.

Refs: https://github.com/nodejs/node/pull/8932#issuecomment-252924107
PR-URL: https://github.com/nodejs/node/pull/9064
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
v6
Andreas Madsen 8 years ago
committed by James M Snell
parent
commit
8a0b7ffac6
  1. 5
      benchmark/common.js

5
benchmark/common.js

@ -208,11 +208,14 @@ Benchmark.prototype.report = function(rate, elapsed) {
}); });
}; };
exports.v8ForceOptimization = function(method, ...args) { exports.v8ForceOptimization = function(method) {
if (typeof method !== 'function') if (typeof method !== 'function')
return; return;
const v8 = require('v8'); const v8 = require('v8');
v8.setFlagsFromString('--allow_natives_syntax'); v8.setFlagsFromString('--allow_natives_syntax');
const args = Array.prototype.slice.call(arguments, 1);
method.apply(null, args); method.apply(null, args);
eval('%OptimizeFunctionOnNextCall(method)'); eval('%OptimizeFunctionOnNextCall(method)');
method.apply(null, args); method.apply(null, args);

Loading…
Cancel
Save