blob: ce72b4d90a543f54263a5715155f712807dfa2dc [file] [log] [blame]
Rahul Ravikumar05336002019-10-14 15:04:32 -07001/*
2 * Copyright (C) 2016 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package benchmarks;
18
19/**
20 * How long does it take to access a string in the dex cache?
21 */
22public class StringDexCacheBenchmark {
23 public int timeStringDexCacheAccess(int reps) {
24 int v = 0;
25 for (int rep = 0; rep < reps; ++rep) {
26 // Deliberately obscured to make optimizations less likely.
27 String s = (rep >= 0) ? "hello, world!" : null;
28 v += s.length();
29 }
30 return v;
31 }
32}