From 6ae4021f382a7b1fe62958b58eb3476ea5d425ad Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 12 Oct 2016 20:23:40 +0200 Subject: [PATCH 1/3] benchmark: fixes csv parsing given no parameters When a benchmark did not contain any parameters the csv configuration filed would be "". In R this is by default parsed as NA, causing NA in the printout too. Fixes: https://github.com/nodejs/node/issues/9061 --- benchmark/compare.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/benchmark/compare.R b/benchmark/compare.R index 1200340f329837..b4316ca7f81600 100644 --- a/benchmark/compare.R +++ b/benchmark/compare.R @@ -16,8 +16,12 @@ if (!is.null(args.options$help) || plot.filename = args.options$plot; -dat = read.csv(file('stdin')); +dat = read.csv( + file('stdin'), + colClasses=c('character', 'character', 'character', 'numeric', 'numeric') +); dat = data.frame(dat); + dat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration); dat$name = paste0(dat$filename, dat$configuration); From d3870a58c92557a03a371e5338551f734c658c34 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 12 Oct 2016 20:28:57 +0200 Subject: [PATCH 2/3] benchmark: change the execution order This changes the execution order from "iter, file, binary" to "file, iter, binary". This means the csv no longer has to buffered completely. This also has the added effect that stopping compare.js early or interfering with performance only affects a single benchmark, instead of all of them. Refs: https://github.com/nodejs/node/issues/8659 --- benchmark/compare.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/compare.js b/benchmark/compare.js index de328d60fcbae0..ea431b18cb4cd9 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -40,8 +40,8 @@ if (benchmarks.length === 0) { // Create queue from the benchmarks list such both node versions are tested // `runs` amount of times each. const queue = []; -for (let iter = 0; iter < runs; iter++) { - for (const filename of benchmarks) { +for (const filename of benchmarks) { + for (let iter = 0; iter < runs; iter++) { for (const binary of binaries) { queue.push({ binary, filename, iter }); } From 09d65310a91da03f111f08d952fceca561d35ef1 Mon Sep 17 00:00:00 2001 From: Andreas Madsen Date: Wed, 12 Oct 2016 20:36:01 +0200 Subject: [PATCH 3/3] 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 --- 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);