From d34cbcd7898db1d36ea113f1edda2cabf0fc5b8c Mon Sep 17 00:00:00 2001 From: Hai Dang Date: Mon, 15 Oct 2018 17:42:31 +0200 Subject: [PATCH] [js-perf-tests] Fix micro-benchmark of spreading double arrays. Array.prototype.map is currently not preserving PACKEDness. Use a for-loop instead. Bug: v8:7980 Change-Id: I08aff1cbcd84b9de260a5a1e2c68b9cfb5c3d888 Reviewed-on: https://chromium-review.googlesource.com/c/1280329 Commit-Queue: Hai Dang Commit-Queue: Georg Neis Reviewed-by: Georg Neis Cr-Commit-Position: refs/heads/master@{#56657} --- .../ArrayLiteralInitialSpreadLargeDoublePacked/run.js | 8 ++++++-- .../ArrayLiteralInitialSpreadLargePacked/run.js | 3 +-- .../ArrayLiteralInitialSpreadSmallDoublePacked/run.js | 8 ++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js b/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js index e53fa90e7f..9b449840ea 100644 --- a/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js +++ b/test/js-perf-test/ArrayLiteralInitialSpreadLargeDoublePacked/run.js @@ -5,8 +5,12 @@ // Comparing different copy schemes against spread initial literals. // Benchmarks for large packed double arrays. -const largeHoleyArray = new Array(1e5); -const largeArray = Array.from(largeHoleyArray.keys()).map(x => x + 6.66); +var largeArray = Array.from(Array(1e5).keys()); +// TODO(dhai): we should be able to use Array.prototype.map here, but that +// implementation is currently creating a HOLEY array. +for (var i = 0; i < 1e5; i++) { + largeArray[i] += 6.66; +} // ---------------------------------------------------------------------------- // Benchmark: Spread diff --git a/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js b/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js index 38643c6903..dc279784cf 100644 --- a/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js +++ b/test/js-perf-test/ArrayLiteralInitialSpreadLargePacked/run.js @@ -5,8 +5,7 @@ // Comparing different copy schemes against spread initial literals. // Benchmarks for large packed arrays. -const largeHoleyArray = new Array(1e5); -const largeArray = Array.from(largeHoleyArray.keys()); +const largeArray = Array.from(Array(1e5).keys()); // ---------------------------------------------------------------------------- // Benchmark: Spread diff --git a/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js b/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js index bca629525f..88d382c4fc 100644 --- a/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js +++ b/test/js-perf-test/ArrayLiteralInitialSpreadSmallDoublePacked/run.js @@ -5,8 +5,12 @@ // Comparing different copy schemes against spread initial literals. // Benchmarks for small packed double arrays. -const smallHoleyArray = Array(100); -const smallArray = Array.from(Array(100).keys()).map(x => x + 6.66);; +var smallArray = Array.from(Array(100).keys()); + +for (var i = 0; i < 100; i++) { + smallArray[i] += 6.66; +} + // ---------------------------------------------------------------------------- // Benchmark: Spread