diff options
author | Evgeny Astigeevich <evgeny.astigeevich@linaro.org> | 2019-06-24 10:21:34 +0100 |
---|---|---|
committer | Evgeny Astigeevich <evgeny.astigeevich@linaro.org> | 2019-10-11 13:02:45 +0100 |
commit | c184f4a3121a6571b79dffd7d39e38ba496f2f24 (patch) | |
tree | ebe95922f0b0784bb329e740e3e6eeee280cc2c4 /benchmarks | |
parent | f66fe09bcc3bbaa52393f08c824999606e25f3d3 (diff) | |
download | art-testing-c184f4a3121a6571b79dffd7d39e38ba496f2f24.tar.gz |
Improve stability of micro/StringEquals.java
The CL contains:
1. Initialization of strings is done with setupStrings method.
2. A number of strings and their lengths are reduced in order not to cause
issues with the L1 cache.
Test: benchmarks_run_target.sh --iterations 10
Change-Id: I314f2597be2005ff71c61318e331ccad3bc150a3
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/micro/StringEquals.java | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/benchmarks/micro/StringEquals.java b/benchmarks/micro/StringEquals.java index 8fc3ab1..70505ce 100644 --- a/benchmarks/micro/StringEquals.java +++ b/benchmarks/micro/StringEquals.java @@ -38,16 +38,12 @@ import java.util.Random; public class StringEquals { private static Random rnd = new Random(0); - private static final int NUM_Equals = 1024; - private static final int STR_Length = 512; - private static String[] randomStrings = new String[NUM_Equals]; - private static Boolean[] equalsResults = new Boolean[NUM_Equals - 1]; + private static final int NUM_Equals = 256; + private static final int STR_Length = 128; + private String[] randomStrings; + public Boolean[] equalsResults; - static { - generateRandomStrings(); - } - - private static void generateRandomStrings() { + private void generateRandomStrings() { for (int i = 0; i < NUM_Equals; i++) { StringBuilder sb = new StringBuilder(); for (int j = 0; j < STR_Length; j++) { @@ -57,6 +53,12 @@ public class StringEquals { } } + public void setupStrings() { + randomStrings = new String[NUM_Equals]; + equalsResults = new Boolean[NUM_Equals - 1]; + generateRandomStrings(); + } + public void timeEquals(int iterations) { for (int i = 0; i < iterations; i++) { for (int j = 0; j < NUM_Equals - 1; j++) { @@ -67,6 +69,7 @@ public class StringEquals { public static void main(String[] args) { StringEquals eq = new StringEquals(); + eq.setupStrings(); long before = System.currentTimeMillis(); eq.timeEquals(1500); eq.timeEquals(1500); |