From 06f37471aa746d2478f31aaf1a6fc91330fcc6bf Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 12 Oct 2016 20:36:01 +0200 Subject: [PATCH] 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 Reviewed-By: Brian White --- benchmark/common.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/benchmark/common.js b/benchmark/common.js index 495d6fdf365871..94f11a2be96933 100644 --- a/benchmark/common.js +++ b/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') 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);