From f6c144af16592bfb38f5442252d915b3b8da9dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 17 Mar 2017 09:21:58 +0100 Subject: [PATCH] benchmark: avoid TurboFan deopt in arrays bench Something unidentified at the moment is causing the arrays benchmarks to deopt when run with the TurboFan compiler. Refactor the test to use an inner function that can be correctly optimized by TurboFan and Crankshaft. Refs: https://github.com/nodejs/node/issues/11851#issuecomment-287106714 --- benchmark/arrays/var-int.js | 6 +++++- benchmark/arrays/zero-float.js | 6 +++++- benchmark/arrays/zero-int.js | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js index 36b0a908a59a4f..9ebad611661929 100644 --- a/benchmark/arrays/var-int.js +++ b/benchmark/arrays/var-int.js @@ -27,9 +27,13 @@ function main(conf) { bench.start(); var arr = new clazz(n * 1e6); for (var i = 0; i < 10; ++i) { + run(); + } + bench.end(n); + + function run() { for (var j = 0, k = arr.length; j < k; ++j) { arr[j] = (j ^ k) & 127; } } - bench.end(n); } diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js index 047e179234f33a..a74cd8ec5bacca 100644 --- a/benchmark/arrays/zero-float.js +++ b/benchmark/arrays/zero-float.js @@ -27,9 +27,13 @@ function main(conf) { bench.start(); var arr = new clazz(n * 1e6); for (var i = 0; i < 10; ++i) { + run(); + } + bench.end(n); + + function run() { for (var j = 0, k = arr.length; j < k; ++j) { arr[j] = 0.0; } } - bench.end(n); } diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js index 4e5c97e8af0b9c..7f61aa1a820042 100644 --- a/benchmark/arrays/zero-int.js +++ b/benchmark/arrays/zero-int.js @@ -27,9 +27,13 @@ function main(conf) { bench.start(); var arr = new clazz(n * 1e6); for (var i = 0; i < 10; ++i) { + run(); + } + bench.end(n); + + function run() { for (var j = 0, k = arr.length; j < k; ++j) { arr[j] = 0; } } - bench.end(n); }