36
36
37
37
import java .util .concurrent .TimeUnit ;
38
38
39
- /**
40
- * Tests allocation profiler.
41
- */
42
39
@ OutputTimeUnit (TimeUnit .NANOSECONDS )
43
40
@ Fork (1 ) // 0 to enable debugging
44
41
public class GCProfilerTest {
45
42
46
43
@ Benchmark
47
44
@ Warmup (iterations = 0 )
48
- @ Measurement (iterations = 20 , time = 10 , timeUnit = TimeUnit .MILLISECONDS )
45
+ @ Measurement (iterations = 10 , time = 10 , timeUnit = TimeUnit .MILLISECONDS )
49
46
@ BenchmarkMode (Mode .AverageTime )
50
47
public Object allocateObjectNoWarmup () {
51
48
return new Object ();
52
49
}
53
50
54
51
@ Benchmark
55
- @ Warmup (iterations = 2 )
52
+ @ Warmup (iterations = 2 , time = 1 , timeUnit = TimeUnit . SECONDS )
56
53
@ Measurement (iterations = 2 , time = 2 , timeUnit = TimeUnit .SECONDS )
57
54
@ BenchmarkMode (Mode .AverageTime )
58
55
public Object allocateObject () {
@@ -68,19 +65,46 @@ public Object allocateObjectSingleShot() {
68
65
}
69
66
70
67
@ Benchmark
71
- @ Warmup (iterations = 2 )
68
+ @ Warmup (iterations = 2 , time = 1 , timeUnit = TimeUnit . SECONDS )
72
69
@ Measurement (iterations = 1 , time = 2 , timeUnit = TimeUnit .SECONDS )
73
70
@ BenchmarkMode (Mode .SampleTime )
74
71
public Object allocateObjectSampleTime () {
75
72
return new Object ();
76
73
}
77
74
78
75
@ Test
79
- public void testAllocationProfiler () throws RunnerException {
76
+ public void testDefault () throws RunnerException {
80
77
Options opts = new OptionsBuilder ()
81
78
.include (Fixtures .getTestMask (this .getClass ()))
82
79
.addProfiler (GCProfiler .class )
83
80
.build ();
84
81
new Runner (opts ).run ();
85
82
}
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
+ }
86
110
}
0 commit comments