Advertisement
Guest User

Untitled

a guest
Mar 9th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. package skunkworks;
  2.  
  3. import jdk.jfr.Recording;
  4. import jdk.jfr.consumer.RecordingFile;
  5.  
  6. import java.io.File;
  7. import java.io.IOException;
  8. import java.util.Map;
  9.  
  10. public class TestCase {
  11.     public static void main(String[] args) throws IOException {
  12.         File tempDir = new File(".");
  13.         var recording = new Recording(Map.of("jdk.ObjectAllocationOutsideTLAB#enabled", "true"));
  14.         recording.setDestination(new File(tempDir.getAbsolutePath(), "rec.jfr").toPath());
  15.         recording.start();
  16.  
  17.         for (int i = 0; i < 10; i++) {
  18.             Thread.currentThread().setName("Iteration-" + i);
  19.             var b = new byte[20 * 1024 * 1024];
  20.         }
  21.  
  22.         recording.stop();
  23.         recording.close();
  24.  
  25.         RecordingFile.readAllEvents(recording.getDestination()).forEach(e ->
  26.                 System.out.println(e.getThread().getJavaName()));
  27.         tempDir.delete();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement