v8/test/js-perf-test/BytecodeHandlers/LdaKeyedProperty.js
Sathya Gunasekaran cc9964bb65 [ic] Add benchmark for LdaKeyedLoad
Bug: v8:9449
Change-Id: I7c50db92459df2a8a7da7b0bd2efdd2f3bed3e46
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1690952
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Auto-Submit: Sathya Gunasekaran <gsathya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62671}
2019-07-12 10:33:11 +00:00

41 lines
939 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 addBenchmark(name, test) {
new BenchmarkSuite(name, [1000],
[
new Benchmark(name, false, false, 0, test)
]);
}
function objectLookupStringConstant() {
const x = { 1: "foo" };
for (var i = 0; i < 1000; ++i) {
const p = x["1"];
}
}
function objectLookupIndexNumber() {
const x = { 1: "foo" };
const a = 1;
for (var i = 0; i < 1000; ++i) {
const p = x[a];
}
}
function objectLookupIndexString() {
const x = { 1: "foo" };
const a = "1";
for (var i = 0; i < 1000; ++i) {
const p = x[a];
}
}
addBenchmark('Object-Lookup-String-Constant', objectLookupStringConstant);
addBenchmark('Object-Lookup-Index-Number', objectLookupIndexNumber);
addBenchmark('Object-Lookup-Index-String', objectLookupIndexString);