summaryrefslogtreecommitdiff
path: root/benchmark/const-string/src/ConstStringBenchmark.java
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2016-11-16 15:40:12 +0000
committerVladimir Marko <vmarko@google.com>2016-11-17 11:30:13 +0000
commitfa1b78f19e689d8fc98e2d5b5ce9746e589fb88b (patch)
treec2a3f73514597ba05856f9cc33e2a97739fa1248 /benchmark/const-string/src/ConstStringBenchmark.java
parentecd8300b94938f22fa3988c58187acce9f091da8 (diff)
Add const-class benchmark.
Also fix indentation in const-string benchmark. Test: vogar --benchmark art/benchmark/const-class/src/ConstClassBenchmark.java Test: vogar --benchmark art/benchmark/const-string/src/ConstStringBenchmark.java Bug: 30627598 Change-Id: I04ca9514f6e647640e2c0d9d65fdc4ace652927a
Diffstat (limited to 'benchmark/const-string/src/ConstStringBenchmark.java')
-rw-r--r--benchmark/const-string/src/ConstStringBenchmark.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/benchmark/const-string/src/ConstStringBenchmark.java b/benchmark/const-string/src/ConstStringBenchmark.java
index 2beb0a4c60..2359a5f1fb 100644
--- a/benchmark/const-string/src/ConstStringBenchmark.java
+++ b/benchmark/const-string/src/ConstStringBenchmark.java
@@ -18,6 +18,7 @@ public class ConstStringBenchmark {
// Initialize 1025 strings with consecutive string indexes in the dex file.
// The tests below rely on the knowledge that ART uses the low 10 bits
// of the string index as the hash into DexCache strings array.
+ // Note: n == n + 1024 (mod 2^10), n + 1 != n + 1023 (mod 2^10).
public static final String string_0000 = "TestString_0000";
public static final String string_0001 = "TestString_0001";
public static final String string_0002 = "TestString_0002";
@@ -1045,21 +1046,21 @@ public class ConstStringBenchmark {
public static final String string_1024 = "TestString_1024";
public void timeConstStringsWithConflict(int count) {
- for (int i = 0; i < count; ++i) {
- $noinline$foo("TestString_0000");
- $noinline$foo("TestString_1024");
- }
+ for (int i = 0; i < count; ++i) {
+ $noinline$foo("TestString_0000");
+ $noinline$foo("TestString_1024");
+ }
}
public void timeConstStringsWithoutConflict(int count) {
- for (int i = 0; i < count; ++i) {
- $noinline$foo("TestString_0001");
- $noinline$foo("TestString_1023");
- }
+ for (int i = 0; i < count; ++i) {
+ $noinline$foo("TestString_0001");
+ $noinline$foo("TestString_1023");
+ }
}
static void $noinline$foo(String s) {
- if (doThrow) { throw new Error(); }
+ if (doThrow) { throw new Error(); }
}
public static boolean doThrow = false;