v8/test/js-perf-test/ObjectFreeze/has-own-property.js
Z Nguyen-Huu 0db46e6a41 add new micro-benchmark of HasOwnProperty for frozen objects
Bug: v8:6831
Change-Id: I906dcc363620fda97f00cb02b68c3e393471076d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1651144
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#62093}
2019-06-11 13:28:25 +00:00

24 lines
514 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 driver(n) {
let result = 0;
for (var i=0;i<n;i++) {
result += frozenArray.hasOwnProperty(''+i)==-1?0:1;
}
return result;
}
function HasOwnProperty() {
driver(1e4);
}
function HasOwnPropertyWarmUp() {
driver(1e1);
driver(1e2);
driver(1e3);
}
createSuite('HasOwnProperty', 10, HasOwnProperty, HasOwnPropertyWarmUp);