test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java
equal
deleted
inserted
replaced
24 package MyPackage; |
24 package MyPackage; |
25 |
25 |
26 /** |
26 /** |
27 * @test |
27 * @test |
28 * @build Frame HeapMonitor |
28 * @build Frame HeapMonitor |
29 * @summary Verifies the JVMTI Heap Monitor rate when allocating arrays. |
29 * @summary Verifies the JVMTI Heap Monitor interval when allocating arrays. |
30 * @compile HeapMonitorStatArrayCorrectnessTest.java |
30 * @compile HeapMonitorStatArrayCorrectnessTest.java |
31 * @run main/othervm/native -agentlib:HeapMonitorTest MyPackage.HeapMonitorStatArrayCorrectnessTest |
31 * @run main/othervm/native -agentlib:HeapMonitorTest MyPackage.HeapMonitorStatArrayCorrectnessTest |
32 */ |
32 */ |
33 |
33 |
34 public class HeapMonitorStatArrayCorrectnessTest { |
34 public class HeapMonitorStatArrayCorrectnessTest { |
56 |
56 |
57 HeapMonitor.enableSamplingEvents(); |
57 HeapMonitor.enableSamplingEvents(); |
58 |
58 |
59 // 111 is as good a number as any. |
59 // 111 is as good a number as any. |
60 final int samplingMultiplier = 111; |
60 final int samplingMultiplier = 111; |
61 HeapMonitor.setSamplingRate(samplingMultiplier * currentSize); |
61 HeapMonitor.setSamplingInterval(samplingMultiplier * currentSize); |
62 |
62 |
63 allocate(currentSize); |
63 allocate(currentSize); |
64 |
64 |
65 HeapMonitor.disableSamplingEvents(); |
65 HeapMonitor.disableSamplingEvents(); |
66 |
66 |
77 double expected = maxIteration; |
77 double expected = maxIteration; |
78 expected *= 4; |
78 expected *= 4; |
79 expected /= samplingMultiplier; |
79 expected /= samplingMultiplier; |
80 |
80 |
81 // 10% error ensures a sanity test without becoming flaky. |
81 // 10% error ensures a sanity test without becoming flaky. |
82 // Flakiness is due to the fact that this test is dependent on the sampling rate, which is a |
82 // Flakiness is due to the fact that this test is dependent on the sampling interval, which is a |
83 // statistical geometric variable around the sampling rate. This means that the test could be |
83 // statistical geometric variable around the sampling interval. This means that the test could be |
84 // unlucky and not achieve the mean average fast enough for the test case. |
84 // unlucky and not achieve the mean average fast enough for the test case. |
85 if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) { |
85 if (!HeapMonitor.statsHaveExpectedNumberSamples((int) expected, 10)) { |
86 throw new RuntimeException("Statistics should show about " + expected + " samples."); |
86 throw new RuntimeException("Statistics should show about " + expected + " samples."); |
87 } |
87 } |
88 } |
88 } |