Java Code Examples for jdk.jfr.consumer.RecordedEvent#getStartTime()

The following examples show how to use jdk.jfr.consumer.RecordedEvent#getStartTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YoungGarbageCollectionEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test() throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0));
    recording.start();
    triggerGC();
    recording.stop();

    boolean isAnyFound = false;
    for (RecordedEvent event : Events.fromRecording(recording)) {
        if (!EVENT_NAME.equals(event.getEventType().getName())) {
            continue;
        }
        System.out.println("Event: " + event);
        isAnyFound = true;
        Events.assertField(event, "gcId").atLeast(0);
        Events.assertField(event, "tenuringThreshold").atLeast(1);

        Instant startTime = event.getStartTime();
        Instant endTime = event.getEndTime();
        Duration duration = event.getDuration();
        assertGreaterThan(startTime, Instant.EPOCH, "startTime should be at least 0");
        assertGreaterThan(endTime, Instant.EPOCH, "endTime should be at least 0");
        // TODO: Maybe we should accept duration of 0, but old test did not.
        assertGreaterThan(duration, Duration.ZERO, "Duration should be above 0");
        assertGreaterThan(endTime, startTime, "End time should be after start time");
    }
    assertTrue(isAnyFound, "No matching event found");
}
 
Example 2
Source File: TestRandomAccessFileThread.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static void logEventSummary(RecordedEvent event) {
    boolean isRead = Events.isEventType(event, IOEvent.EVENT_FILE_READ);
    String name = isRead ? "read " : "write";
    String bytesField = isRead ? "bytesRead" : "bytesWritten";
    long bytes = Events.assertField(event, bytesField).getValue();
    long commit = Events.assertField(event, "startTime").getValue();
    Instant start = event.getStartTime();
    Instant end = event.getEndTime();
    System.out.printf("%s: bytes=%d, commit=%d, start=%s, end=%s%n", name, bytes, commit, start, end);
}
 
Example 3
Source File: YoungGarbageCollectionEvent.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void test() throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0));
    recording.start();
    triggerGC();
    recording.stop();

    boolean isAnyFound = false;
    for (RecordedEvent event : Events.fromRecording(recording)) {
        if (!EVENT_NAME.equals(event.getEventType().getName())) {
            continue;
        }
        System.out.println("Event: " + event);
        isAnyFound = true;
        Events.assertField(event, "gcId").atLeast(0);
        Events.assertField(event, "tenuringThreshold").atLeast(1);

        Instant startTime = event.getStartTime();
        Instant endTime = event.getEndTime();
        Duration duration = event.getDuration();
        assertGreaterThan(startTime, Instant.EPOCH, "startTime should be at least 0");
        assertGreaterThan(endTime, Instant.EPOCH, "endTime should be at least 0");
        // TODO: Maybe we should accept duration of 0, but old test did not.
        assertGreaterThan(duration, Duration.ZERO, "Duration should be above 0");
        assertGreaterThan(endTime, startTime, "End time should be after start time");
    }
    assertTrue(isAnyFound, "No matching event found");
}
 
Example 4
Source File: GCHelper.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public String toString() {
    RecordedEvent endEvent = getEndEvent();
    Instant startTime = Instant.EPOCH;
    String cause = "?";
    String name = "?";
    if (endEvent != null) {
        name = getName();
        startTime = endEvent.getStartTime();
        cause = Events.assertField(endEvent, "cause").getValue();
    }
    return String.format("GcEvent: gcId=%d, method=%s, cause=%s, startTime=%s",
            getGcId(), name, cause, startTime);
}
 
Example 5
Source File: YoungGarbageCollectionEvent.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void test() throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0));
    recording.start();
    triggerGC();
    recording.stop();

    boolean isAnyFound = false;
    for (RecordedEvent event : Events.fromRecording(recording)) {
        if (!EVENT_NAME.equals(event.getEventType().getName())) {
            continue;
        }
        System.out.println("Event: " + event);
        isAnyFound = true;
        Events.assertField(event, "gcId").atLeast(0);
        Events.assertField(event, "tenuringThreshold").atLeast(1);

        Instant startTime = event.getStartTime();
        Instant endTime = event.getEndTime();
        Duration duration = event.getDuration();
        assertGreaterThan(startTime, Instant.EPOCH, "startTime should be at least 0");
        assertGreaterThan(endTime, Instant.EPOCH, "endTime should be at least 0");
        // TODO: Maybe we should accept duration of 0, but old test did not.
        assertGreaterThan(duration, Duration.ZERO, "Duration should be above 0");
        assertGreaterThan(endTime, startTime, "End time should be after start time");
    }
    assertTrue(isAnyFound, "No matching event found");
}
 
Example 6
Source File: TestRandomAccessFileThread.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static void logEventSummary(RecordedEvent event) {
    boolean isRead = Events.isEventType(event, IOEvent.EVENT_FILE_READ);
    String name = isRead ? "read " : "write";
    String bytesField = isRead ? "bytesRead" : "bytesWritten";
    long bytes = Events.assertField(event, bytesField).getValue();
    long commit = Events.assertField(event, "startTime").getValue();
    Instant start = event.getStartTime();
    Instant end = event.getEndTime();
    System.out.printf("%s: bytes=%d, commit=%d, start=%s, end=%s%n", name, bytes, commit, start, end);
}
 
Example 7
Source File: GCHelper.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String toString() {
    RecordedEvent endEvent = getEndEvent();
    Instant startTime = Instant.EPOCH;
    String cause = "?";
    String name = "?";
    if (endEvent != null) {
        name = getName();
        startTime = endEvent.getStartTime();
        cause = Events.assertField(endEvent, "cause").getValue();
    }
    return String.format("GcEvent: gcId=%d, method=%s, cause=%s, startTime=%s",
            getGcId(), name, cause, startTime);
}
 
Example 8
Source File: YoungGarbageCollectionEvent.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void test() throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME).withThreshold(Duration.ofMillis(0));
    recording.start();
    triggerGC();
    recording.stop();

    boolean isAnyFound = false;
    for (RecordedEvent event : Events.fromRecording(recording)) {
        if (!EVENT_NAME.equals(event.getEventType().getName())) {
            continue;
        }
        System.out.println("Event: " + event);
        isAnyFound = true;
        Events.assertField(event, "gcId").atLeast(0);
        Events.assertField(event, "tenuringThreshold").atLeast(1);

        Instant startTime = event.getStartTime();
        Instant endTime = event.getEndTime();
        Duration duration = event.getDuration();
        assertGreaterThan(startTime, Instant.EPOCH, "startTime should be at least 0");
        assertGreaterThan(endTime, Instant.EPOCH, "endTime should be at least 0");
        // TODO: Maybe we should accept duration of 0, but old test did not.
        assertGreaterThan(duration, Duration.ZERO, "Duration should be above 0");
        assertGreaterThan(endTime, startTime, "End time should be after start time");
    }
    assertTrue(isAnyFound, "No matching event found");
}
 
Example 9
Source File: TestRandomAccessFileThread.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static void logEventSummary(RecordedEvent event) {
    boolean isRead = Events.isEventType(event, IOEvent.EVENT_FILE_READ);
    String name = isRead ? "read " : "write";
    String bytesField = isRead ? "bytesRead" : "bytesWritten";
    long bytes = Events.assertField(event, bytesField).getValue();
    long commit = Events.assertField(event, "startTime").getValue();
    Instant start = event.getStartTime();
    Instant end = event.getEndTime();
    System.out.printf("%s: bytes=%d, commit=%d, start=%s, end=%s%n", name, bytes, commit, start, end);
}
 
Example 10
Source File: GCHelper.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public String toString() {
    RecordedEvent endEvent = getEndEvent();
    Instant startTime = Instant.EPOCH;
    String cause = "?";
    String name = "?";
    if (endEvent != null) {
        name = getName();
        startTime = endEvent.getStartTime();
        cause = Events.assertField(endEvent, "cause").getValue();
    }
    return String.format("GcEvent: gcId=%d, method=%s, cause=%s, startTime=%s",
            getGcId(), name, cause, startTime);
}