224 }
225 }
226 }
227 Asserts.assertTrue(lastGcId != -1, "No gcId found");
228 return lastGcId;
229 }
230
231 /**
232 * Verifies collection count reported by flight recorder events against the values
233 * reported by GarbageCollectionMXBean.
234 * Number of collections should match exactly.
235 * Sum pause time are allowed some margin of error because of rounding errors in measurements.
236 */
237 private void verifyCollectionCount(GCHelper.CollectionSummary eventCounts, GCHelper.CollectionSummary beanCounts) {
238 verifyCollectionCount(youngCollector, eventCounts.collectionCountYoung, beanCounts.collectionCountYoung);
239 verifyCollectionCount(oldCollector, eventCounts.collectionCountOld, beanCounts.collectionCountOld);
240 }
241
242 private void verifyCollectionCount(String collector, long eventCounts, long beanCounts) {
243 if (GCHelper.gcG1Old.equals(oldCollector)) {
244 // ConcurrentMarkSweep mixes old and new collections. Not same values as in MXBean.
245 // MXBean does not report old collections for G1Old, so we have nothing to compare with.
246 return;
247 }
248 // JFR events and GarbageCollectorMXBean events are not updated at the same time.
249 // This means that number of collections may diff.
250 // We allow a diff of +- 1 collection count.
251 long minCount = Math.max(0, beanCounts - 1);
252 long maxCount = beanCounts + 1;
253 Asserts.assertGreaterThanOrEqual(eventCounts, minCount, "Too few event counts for collector " + collector);
254 Asserts.assertLessThanOrEqual(eventCounts, maxCount, "Too many event counts for collector " + collector);
255 }
256
257 /**
258 * Verifies that all events belonging to a single GC are ok.
259 * A GcBatch contains all flight recorder events that belong to a single GC.
260 */
261 private void verifySingleGcBatch(List<GCHelper.GcBatch> batches) {
262 for (GCHelper.GcBatch batch : batches) {
263 //System.out.println("batch:\r\n" + batch.getLog());
264 try {
|
224 }
225 }
226 }
227 Asserts.assertTrue(lastGcId != -1, "No gcId found");
228 return lastGcId;
229 }
230
231 /**
232 * Verifies collection count reported by flight recorder events against the values
233 * reported by GarbageCollectionMXBean.
234 * Number of collections should match exactly.
235 * Sum pause time are allowed some margin of error because of rounding errors in measurements.
236 */
237 private void verifyCollectionCount(GCHelper.CollectionSummary eventCounts, GCHelper.CollectionSummary beanCounts) {
238 verifyCollectionCount(youngCollector, eventCounts.collectionCountYoung, beanCounts.collectionCountYoung);
239 verifyCollectionCount(oldCollector, eventCounts.collectionCountOld, beanCounts.collectionCountOld);
240 }
241
242 private void verifyCollectionCount(String collector, long eventCounts, long beanCounts) {
243 if (GCHelper.gcG1Old.equals(oldCollector)) {
244 // MXBean does not report old collections for G1Old, so we have nothing to compare with.
245 return;
246 }
247 // JFR events and GarbageCollectorMXBean events are not updated at the same time.
248 // This means that number of collections may diff.
249 // We allow a diff of +- 1 collection count.
250 long minCount = Math.max(0, beanCounts - 1);
251 long maxCount = beanCounts + 1;
252 Asserts.assertGreaterThanOrEqual(eventCounts, minCount, "Too few event counts for collector " + collector);
253 Asserts.assertLessThanOrEqual(eventCounts, maxCount, "Too many event counts for collector " + collector);
254 }
255
256 /**
257 * Verifies that all events belonging to a single GC are ok.
258 * A GcBatch contains all flight recorder events that belong to a single GC.
259 */
260 private void verifySingleGcBatch(List<GCHelper.GcBatch> batches) {
261 for (GCHelper.GcBatch batch : batches) {
262 //System.out.println("batch:\r\n" + batch.getLog());
263 try {
|