From fa1b78f19e689d8fc98e2d5b5ce9746e589fb88b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 16 Nov 2016 15:40:12 +0000 Subject: 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 --- benchmark/const-string/src/ConstStringBenchmark.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'benchmark/const-string/src/ConstStringBenchmark.java') 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; -- cgit v1.2.3-59-g8ed1b