v8/test/js-perf-test/ObjectFreeze/array-map.js
Z Nguyen-Huu aff557b61b add micro-benchmark of Array.map for frozen objects
Bug: v8:6831
Change-Id: I79cd1e25ddca17f0d5026bee737cd3fde0041e85
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1653733
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62124}
2019-06-12 16:37:07 +00:00

33 lines
674 B
JavaScript

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function setupArrayMap(length) {
var a = new Array(length);
for (var i=0;i<length;i++) {
a[i] = ''+i;
}
return Object.freeze(a);
}
const frozenArrayMap = setupArrayMap(200);
function driverArrayMap(n) {
let result = 0;
for (var i=0;i<n;i++) {
result = frozenArrayMap.map(Number);
}
return result;
}
function ArrayMap() {
driverArrayMap(1e3);
}
function ArrayMapWarmUp() {
driverArrayMap(1e1);
driverArrayMap(1e2);
}
createSuite('ArrayMap', 10, ArrayMap, ArrayMapWarmUp);