diff options
author | Lokesh Gidra <lokeshgidra@google.com> | 2020-09-23 09:36:01 -0700 |
---|---|---|
committer | Treehugger Robot <treehugger-gerrit@google.com> | 2020-09-24 22:53:52 +0000 |
commit | a48f6f1d64bf4606c6f100eb6dae674409d184cd (patch) | |
tree | fb2c07ef3845da03834a4a63e960cf8127896725 /test/096-array-copy-concurrent-gc/src/Main.java | |
parent | d9a7d0abcba766114d7b64311ea3aee4a66b2154 (diff) |
Replace inlined string allocations to loop in 096-array-copy-concurrent
Replacing inlined string allocations with a loop is expected to reduce
the number of GC invocations in case of GC-stress mode. Hopefully, this
will fix the timeout that is being observed.
Bug: 169242013
Test: art/test/testrunner/testrunner.py --host -t 096-array-copy-concurrent
Change-Id: Ib5c4130a5369749f1c28496cc2a1849f776a45be
Diffstat (limited to 'test/096-array-copy-concurrent-gc/src/Main.java')
-rw-r--r-- | test/096-array-copy-concurrent-gc/src/Main.java | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/test/096-array-copy-concurrent-gc/src/Main.java b/test/096-array-copy-concurrent-gc/src/Main.java index 3cf791a555..eddde11b44 100644 --- a/test/096-array-copy-concurrent-gc/src/Main.java +++ b/test/096-array-copy-concurrent-gc/src/Main.java @@ -44,6 +44,15 @@ public class Main { Object [] array = new Object[8000]; + void allocateFourStrings() { + for (int i = 0; i < 4; i++) { + String str = new String("Creating some garbage" + Math.random()); + if (str.length() < 22) { + System.out.println("bad length"); + } + } + } + void stressArray(boolean doLog) { // We want many references in the array // We also want elements close to each other to have large @@ -63,20 +72,14 @@ public class Main { Object obj = array[array.length - 1]; System.arraycopy(array, 0, array, 1, array.length - 1); array[0] = obj; - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); + allocateFourStrings(); } for (int j = 0; j < array.length; j++) { Object obj = array[0]; System.arraycopy(array, 1, array, 0, array.length - 1); array[array.length - 1] = obj; - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); - new String("Creating some garbage" + Math.random()); + allocateFourStrings(); } if (doLog) { |