diff options
| author | 2018-01-31 14:32:09 +0000 | |
|---|---|---|
| committer | 2018-01-31 14:32:09 +0000 | |
| commit | f346af51a5d44ee0a3cd26e7e0e1b28ec1c5579f (patch) | |
| tree | 60c516a8f92602639e459d23876a8168c2314c11 | |
| parent | 95fa4fd338f1716eadc378a1eea15d5b178dac83 (diff) | |
| parent | 4732f12651a7dc2d37bb75580a5b3add920f3955 (diff) | |
Merge "Add an operation performing non-moving allocation in ThreadStress."
| -rw-r--r-- | test/004-ThreadStress/src-art/Main.java (renamed from test/004-ThreadStress/src/Main.java) | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/test/004-ThreadStress/src/Main.java b/test/004-ThreadStress/src-art/Main.java index c03a9120bf..0d469fb8d9 100644 --- a/test/004-ThreadStress/src/Main.java +++ b/test/004-ThreadStress/src-art/Main.java @@ -14,6 +14,8 @@ * limitations under the License. */ +import dalvik.system.VMRuntime; + import java.lang.reflect.*; import java.util.ArrayList; import java.util.Arrays; @@ -32,25 +34,26 @@ import java.util.concurrent.Semaphore; // (It is important to pass Main if you want to give parameters...) // // ThreadStress command line parameters: -// -n X ............ number of threads -// -d X ............ number of daemon threads -// -o X ............ number of overall operations -// -t X ............ number of operations per thread -// -p X ............ number of permits granted by semaphore -// --dumpmap ....... print the frequency map -// --locks-only .... select a pre-set frequency map with lock-related operations only -// --allocs-only ... select a pre-set frequency map with allocation-related operations only -// -oom:X .......... frequency of OOM (double) -// -sigquit:X ...... frequency of SigQuit (double) -// -alloc:X ........ frequency of Alloc (double) -// -largealloc:X ... frequency of LargeAlloc (double) -// -stacktrace:X ... frequency of StackTrace (double) -// -exit:X ......... frequency of Exit (double) -// -sleep:X ........ frequency of Sleep (double) -// -wait:X ......... frequency of Wait (double) -// -timedwait:X .... frequency of TimedWait (double) -// -syncandwork:X .. frequency of SyncAndWork (double) -// -queuedwait:X ... frequency of QueuedWait (double) +// -n X .............. number of threads +// -d X .............. number of daemon threads +// -o X .............. number of overall operations +// -t X .............. number of operations per thread +// -p X .............. number of permits granted by semaphore +// --dumpmap ......... print the frequency map +// --locks-only ...... select a pre-set frequency map with lock-related operations only +// --allocs-only ..... select a pre-set frequency map with allocation-related operations only +// -oom:X ............ frequency of OOM (double) +// -sigquit:X ........ frequency of SigQuit (double) +// -alloc:X .......... frequency of Alloc (double) +// -largealloc:X ..... frequency of LargeAlloc (double) +// -nonmovingalloc:X.. frequency of NonMovingAlloc (double) +// -stacktrace:X ..... frequency of StackTrace (double) +// -exit:X ........... frequency of Exit (double) +// -sleep:X .......... frequency of Sleep (double) +// -wait:X ........... frequency of Wait (double) +// -timedwait:X ...... frequency of TimedWait (double) +// -syncandwork:X .... frequency of SyncAndWork (double) +// -queuedwait:X ..... frequency of QueuedWait (double) public class Main implements Runnable { @@ -158,6 +161,25 @@ public class Main implements Runnable { } } + private final static class NonMovingAlloc extends Operation { + private final static int ALLOC_SIZE = 1024; // Needs to be small enough to not be in LOS. + private final static int ALLOC_COUNT = 1024; + private final static VMRuntime runtime = VMRuntime.getRuntime(); + + @Override + public boolean perform() { + try { + List<byte[]> l = new ArrayList<byte[]>(); + for (int i = 0; i < ALLOC_COUNT; i++) { + l.add((byte[]) runtime.newNonMovableArray(byte.class, ALLOC_SIZE)); + } + } catch (OutOfMemoryError e) { + } + return true; + } + } + + private final static class StackTrace extends Operation { @Override public boolean perform() { @@ -293,8 +315,9 @@ public class Main implements Runnable { Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>(); frequencyMap.put(new OOM(), 0.005); // 1/200 frequencyMap.put(new SigQuit(), 0.095); // 19/200 - frequencyMap.put(new Alloc(), 0.225); // 45/200 + frequencyMap.put(new Alloc(), 0.2); // 40/200 frequencyMap.put(new LargeAlloc(), 0.05); // 10/200 + frequencyMap.put(new NonMovingAlloc(), 0.025); // 5/200 frequencyMap.put(new StackTrace(), 0.1); // 20/200 frequencyMap.put(new Exit(), 0.225); // 45/200 frequencyMap.put(new Sleep(), 0.125); // 25/200 @@ -308,8 +331,9 @@ public class Main implements Runnable { private final static Map<Operation, Double> createAllocFrequencyMap() { Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>(); frequencyMap.put(new Sleep(), 0.2); // 40/200 - frequencyMap.put(new Alloc(), 0.65); // 130/200 + frequencyMap.put(new Alloc(), 0.575); // 115/200 frequencyMap.put(new LargeAlloc(), 0.15); // 30/200 + frequencyMap.put(new NonMovingAlloc(), 0.075); // 15/200 return frequencyMap; } |