Mercurial > hg > gc-bench
view src/main/java/org/openjdk/gcbench/roots/Strings.java @ 58:d41292cbeb90
Tuneup roots.* tests.
author | shade |
---|---|
date | Mon, 19 Dec 2016 18:56:24 +0100 |
parents | 13d138f3c591 |
children | 583fef4276f5 |
line wrap: on
line source
package org.openjdk.gcbench.roots; import org.openjdk.jmh.annotations.*; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(1) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(Threads.MAX) @State(Scope.Benchmark) public class Strings { List<String> list; @Param({"100000"}) private int size; @Setup public void setup() { list = new ArrayList<>(); for (int c = 0; c < size; c++) { String s = "" + c + "root"; list.add(s.intern()); } } @Benchmark public Object test() throws InterruptedException { // allocation pressure to trigger GCs return new byte[64]; } }