@@ -67,6 +67,7 @@ public static void main(String... arg) throws Exception {
6767 if (cl != null ) {
6868 if (cl .getType ().getName ().contains ("PlatformClassLoader" )) {
6969 classLoaderStatistics .add (e .getStartTime ());
70+ System .out .println ("Class loader" + e );
7071 }
7172 }
7273 });
@@ -87,20 +88,20 @@ public static void main(String... arg) throws Exception {
8788 r1 .stop ();
8889 long chunkFiles = filesInRepository ();
8990 System .out .println ("Number of chunk files: " + chunkFiles );
91+ // When jdk.PhysicalMemory is expected to be emitted:
92+ // Chunk 1: begin, end
93+ // Chunk 2: begin, end
94+ // Chunk 3: begin, end
95+ // Chunk 4: begin, end
96+ assertCount (r1 , "jdk.PhysicalMemory" , physicalMemory , 2 * chunkFiles );
9097 // When jdk.ClassLoaderStatistics and jdk.ThreadThreadDump are expected to be
9198 // emitted:
9299 // Chunk 1: begin, end
93100 // Chunk 2: begin, end
94101 // Chunk 3: end
95102 // Chunk 4: end
96- assertCount ("jdk.ThreadDump" , threadDumps , 2 + 2 + (chunkFiles - 2 ));
97- assertCount ("jdk.ClassLoaderStatistics" , classLoaderStatistics , 2 + 2 + (chunkFiles - 2 ));
98- // When jdk.PhysicalMemory is expected to be emitted:
99- // Chunk 1: begin, end
100- // Chunk 2: begin, end
101- // Chunk 3: begin, end
102- // Chunk 4: begin, end
103- assertCount ("jdk.PhysicalMemory" , physicalMemory , 2 * chunkFiles );
103+ assertCount (r1 , "jdk.ThreadDump" , threadDumps , 2 + 2 + (chunkFiles - 2 ));
104+ assertCount (r1 , "jdk.ClassLoaderStatistics" , classLoaderStatistics , 2 + 2 + (chunkFiles - 2 ));
104105 }
105106 }
106107
@@ -109,13 +110,15 @@ private static long filesInRepository() throws IOException {
109110 return Files .list (repository ).filter (p -> p .toString ().endsWith (".jfr" )).count ();
110111 }
111112
112- private static void assertCount (String eventName , Set <Instant > timestamps , long expected ) throws Exception {
113+ private static void assertCount (RecordingStream stream , String eventName , Set <Instant > timestamps , long expected ) throws Exception {
113114 System .out .println ("Timestamps for " + eventName + ":" );
114115 for (Instant timestamp : timestamps ) {
115116 System .out .println (timestamp );
116117 }
117118 int count = timestamps .size ();
118119 if (count != expected ) {
120+ System .out .println ("Dumping failure file." );
121+ stream .dump (Path .of ("failure.jfr" ));
119122 throw new Exception ("Expected " + expected + " timestamps for event " + eventName + ", but got " + count );
120123 }
121124 }
0 commit comments