Skip to content
Permalink
Browse files
8247266: Speed up test\jdk\jdk\jfr\event\gc\detailed\TestZUncommitEve…
…nt.java

Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Jun 10, 2020
1 parent 1dc7929 commit 7e3d4f8c4f8531644976bb1d65dc2450c4435138
Showing 1 changed file with 14 additions and 10 deletions.
@@ -26,10 +26,12 @@
package jdk.jfr.event.gc.detailed;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

import static gc.testlibrary.Allocation.blackHole;
import jdk.jfr.Recording;
import jdk.jfr.consumer.RecordedEvent;
import jdk.jfr.consumer.RecordingStream;
import jdk.test.lib.jfr.EventNames;
import jdk.test.lib.jfr.Events;

@@ -43,24 +45,26 @@

public class TestZUncommitEvent {
public static void main(String[] args) throws Exception {
try (Recording recording = new Recording()) {
// Activate the event we are interested in and start recording
recording.enable(EventNames.ZUncommit);
recording.start();
List<RecordedEvent> events = new CopyOnWriteArrayList<>();
try (RecordingStream stream = new RecordingStream()) {
// Activate the event
stream.enable(EventNames.ZUncommit);
stream.onEvent(e -> {
// Got event, close stream
events.add(e);
stream.close();
});
// Start recording
stream.startAsync();

// Allocate a large object, to force heap usage above min heap size
blackHole(new byte[32 * 1024 * 1024]);

// Collect
System.gc();

// Wait for uncommit to happen
Thread.sleep(10 * 1000);
stream.awaitTermination();

recording.stop();

// Verify recording
List<RecordedEvent> events = Events.fromRecording(recording);
System.out.println("Events: " + events.size());
Events.hasEvents(events);
}

0 comments on commit 7e3d4f8

Please sign in to comment.