Skip to content

Commit

Permalink
benchmark: use node v4 syntax in common.js
Browse files Browse the repository at this point in the history
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: #8932 (comment)
PR-URL: #9064
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
  • Loading branch information
AndreasMadsen authored and jasnell committed Oct 17, 2016
1 parent 8b152fc commit 06f3747
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion benchmark/common.js
Expand Up @@ -208,11 +208,14 @@ Benchmark.prototype.report = function(rate, elapsed) {
});
};

exports.v8ForceOptimization = function(method, ...args) {
exports.v8ForceOptimization = function(method) {
if (typeof method !== 'function')
return;

const v8 = require('v8');
v8.setFlagsFromString('--allow_natives_syntax');

const args = Array.prototype.slice.call(arguments, 1);
method.apply(null, args);
eval('%OptimizeFunctionOnNextCall(method)');
method.apply(null, args);
Expand Down

0 comments on commit 06f3747

Please sign in to comment.