Skip to content

Commit 0cffac9

Browse files
authored
7903369: JMH: GC profiler options
1 parent e7b1218 commit 0cffac9

File tree

3 files changed

+160
-86
lines changed

3 files changed

+160
-86
lines changed

jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerAllocRateTest.java

+16-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,24 @@ public Object allocate() {
5353
}
5454

5555
@Test
56-
public void test() throws RunnerException {
56+
public void testDefault() throws RunnerException {
57+
testWith("");
58+
}
59+
60+
@Test
61+
public void testAlloc() throws RunnerException {
62+
testWith("alloc=true");
63+
}
64+
65+
@Test
66+
public void testAll() throws RunnerException {
67+
testWith("alloc=true;churn=true");
68+
}
69+
70+
private void testWith(String initLine) throws RunnerException {
5771
Options opts = new OptionsBuilder()
5872
.include(Fixtures.getTestMask(this.getClass()))
59-
.addProfiler(GCProfiler.class)
73+
.addProfiler(GCProfiler.class, initLine)
6074
.build();
6175

6276
RunResult rr = new Runner(opts).runSingle();

jmh-core-it/src/test/java/org/openjdk/jmh/it/profilers/GCProfilerTest.java

+31-7
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,20 @@
3636

3737
import java.util.concurrent.TimeUnit;
3838

39-
/**
40-
* Tests allocation profiler.
41-
*/
4239
@OutputTimeUnit(TimeUnit.NANOSECONDS)
4340
@Fork(1) // 0 to enable debugging
4441
public class GCProfilerTest {
4542

4643
@Benchmark
4744
@Warmup(iterations = 0)
48-
@Measurement(iterations = 20, time = 10, timeUnit = TimeUnit.MILLISECONDS)
45+
@Measurement(iterations = 10, time = 10, timeUnit = TimeUnit.MILLISECONDS)
4946
@BenchmarkMode(Mode.AverageTime)
5047
public Object allocateObjectNoWarmup() {
5148
return new Object();
5249
}
5350

5451
@Benchmark
55-
@Warmup(iterations = 2)
52+
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
5653
@Measurement(iterations = 2, time = 2, timeUnit = TimeUnit.SECONDS)
5754
@BenchmarkMode(Mode.AverageTime)
5855
public Object allocateObject() {
@@ -68,19 +65,46 @@ public Object allocateObjectSingleShot() {
6865
}
6966

7067
@Benchmark
71-
@Warmup(iterations = 2)
68+
@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS)
7269
@Measurement(iterations = 1, time = 2, timeUnit = TimeUnit.SECONDS)
7370
@BenchmarkMode(Mode.SampleTime)
7471
public Object allocateObjectSampleTime() {
7572
return new Object();
7673
}
7774

7875
@Test
79-
public void testAllocationProfiler() throws RunnerException {
76+
public void testDefault() throws RunnerException {
8077
Options opts = new OptionsBuilder()
8178
.include(Fixtures.getTestMask(this.getClass()))
8279
.addProfiler(GCProfiler.class)
8380
.build();
8481
new Runner(opts).run();
8582
}
83+
84+
@Test
85+
public void testAlloc() throws RunnerException {
86+
Options opts = new OptionsBuilder()
87+
.include(Fixtures.getTestMask(this.getClass()))
88+
.addProfiler(GCProfiler.class, "alloc=true")
89+
.build();
90+
new Runner(opts).run();
91+
}
92+
93+
@Test
94+
public void testChurn() throws RunnerException {
95+
Options opts = new OptionsBuilder()
96+
.include(Fixtures.getTestMask(this.getClass()))
97+
.addProfiler(GCProfiler.class, "churn=true;churnWait=1")
98+
.build();
99+
new Runner(opts).run();
100+
}
101+
102+
@Test
103+
public void testAll() throws RunnerException {
104+
Options opts = new OptionsBuilder()
105+
.include(Fixtures.getTestMask(this.getClass()))
106+
.addProfiler(GCProfiler.class, "alloc=true;churn=true;churnWait=1")
107+
.build();
108+
new Runner(opts).run();
109+
}
86110
}

0 commit comments

Comments
 (0)