< prev index next >

test/hotspot/jtreg/serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatRateTest.java

Print this page
rev 49644 : [mq]: event_rebased
rev 49645 : [mq]: heap9
rev 49649 : [mq]: heap14

*** 33,48 **** public class HeapMonitorStatRateTest { private native static double getAverageRate(); ! public static void main(String[] args) { ! int[] tab = {1024, 16384, 524288}; ! ! for (int rateIdx = 0; rateIdx < tab.length; rateIdx++) { ! int rate = tab[rateIdx]; ! HeapMonitor.resetEventStorage(); HeapMonitor.setSamplingRate(rate); HeapMonitor.enableSamplingEvents(); --- 33,43 ---- public class HeapMonitorStatRateTest { private native static double getAverageRate(); ! private static boolean testRateOnce(int rate, boolean throwIfFailure) { HeapMonitor.resetEventStorage(); HeapMonitor.setSamplingRate(rate); HeapMonitor.enableSamplingEvents();
*** 55,66 **** double expectedCount = allocationTotal / rate; double error = Math.abs(actualCount - expectedCount); double errorPercentage = error / expectedCount * 100; ! if (errorPercentage > 10) { throw new RuntimeException("Rate average over 10% for rate " + rate + " -> " + actualCount + ", " + expectedCount); } } } } --- 50,81 ---- double expectedCount = allocationTotal / rate; double error = Math.abs(actualCount - expectedCount); double errorPercentage = error / expectedCount * 100; ! boolean failure = (errorPercentage > 10.0); ! ! if (failure && throwIfFailure) { throw new RuntimeException("Rate average over 10% for rate " + rate + " -> " + actualCount + ", " + expectedCount); } + + return failure; + } + + + private static void testRate(int rate) { + // Test the rate twice, it can happen that the test is "unlucky" and the rate just goes above + // the 10% mark. So try again to squash flakiness. + if (!testRateOnce(rate, false)) { + testRateOnce(rate, true); + } + } + + public static void main(String[] args) { + int[] tab = {1024, 16384, 524288}; + + for (int rateIdx = 0; rateIdx < tab.length; rateIdx++) { + testRate(tab[rateIdx]); } } }
< prev index next >