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

The following examples show how to use jdk.jfr.consumer.RecordedEvent#toString() . 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: TestFormatMissingValue.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    try (Recording r = new Recording()) {
        r.start();
        MultiContentTypeEvent m = new MultiContentTypeEvent();
        m.commit();
        r.stop();
        for (RecordedEvent e : Events.fromRecording(r)) {
            String t = e.toString();
            assertContains(t, "a = N/A");
            assertContains(t, "c = N/A");
            assertContains(t, "e = N/A");
            assertContains(t, "g = N/A");
            assertContains(t, "h = N/A");
            assertContains(t, "j = N/A");

            assertNotContains(t, "b = N/A");
            assertNotContains(t, "d = N/A");
            assertNotContains(t, "f = N/A");
            assertNotContains(t, "i = N/A");
        }
    }
}
 
Example 2
Source File: TestFormatMissingValue.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    try (Recording r = new Recording()) {
        r.start();
        MultiContentTypeEvent m = new MultiContentTypeEvent();
        m.commit();
        r.stop();
        for (RecordedEvent e : Events.fromRecording(r)) {
            String t = e.toString();
            assertContains(t, "a = N/A");
            assertContains(t, "c = N/A");
            assertContains(t, "e = N/A");
            assertContains(t, "g = N/A");
            assertContains(t, "h = N/A");
            assertContains(t, "j = N/A");

            assertNotContains(t, "b = N/A");
            assertNotContains(t, "d = N/A");
            assertNotContains(t, "f = N/A");
            assertNotContains(t, "i = N/A");
        }
    }
}
 
Example 3
Source File: TestToString.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        try (Recording recording = new Recording()) {
            recording.start();
            HelloWorldEvent event = new HelloWorldEvent();
            event.message = "hello, world";
            event.integer = 4711;
            event.floatValue = 9898;
            event.doubleValue = 313;
            event.clazz = HashMap.class;
            event.characater = '&';
            event.byteValue = (byte) 123;
            event.longValue = 1234567890L;
            event.shortValue = 64;
            event.booleanValue = false;
            event.commit();
            recording.stop();
            List<RecordedEvent> events = Events.fromRecording(recording);
            Events.hasEvents(events);
            RecordedEvent e = events.get(0);
            String toString = e.toString();
            System.out.println(toString);
            Asserts.assertTrue(toString.contains("hello, world"), "Missing String field value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("4711"), "Missing integer fields value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("313"), "Missing double value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("HashMap"), "Missing class value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("1234567890"), "Missing long value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("&"), "Missing char value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("123"), "Missing byte value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("64"), "Missing short value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("false"), "Missing boolean value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("HelloWorldEvent"), "Missing class name in RecordedEvent#toString()");
        }
    }
 
Example 4
Source File: TestToString.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        try (Recording recording = new Recording()) {
            recording.start();
            HelloWorldEvent event = new HelloWorldEvent();
            event.message = "hello, world";
            event.integer = 4711;
            event.floatValue = 9898;
            event.doubleValue = 313;
            event.clazz = HashMap.class;
            event.characater = '&';
            event.byteValue = (byte) 123;
            event.longValue = 1234567890L;
            event.shortValue = 64;
            event.booleanValue = false;
            event.commit();
            recording.stop();
            List<RecordedEvent> events = Events.fromRecording(recording);
            Events.hasEvents(events);
            RecordedEvent e = events.get(0);
            String toString = e.toString();
            System.out.println(toString);
            Asserts.assertTrue(toString.contains("hello, world"), "Missing String field value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("4711"), "Missing integer fields value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("313"), "Missing double value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("HashMap"), "Missing class value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("1234567890"), "Missing long value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("&"), "Missing char value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("123"), "Missing byte value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("64"), "Missing short value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("false"), "Missing boolean value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("HelloWorldEvent"), "Missing class name in RecordedEvent#toString()");
        }
    }
 
Example 5
Source File: TestToString.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Throwable {

        try (Recording recording = new Recording()) {
            recording.start();
            HelloWorldEvent event = new HelloWorldEvent();
            event.message = "hello, world";
            event.integer = 4711;
            event.floatValue = 9898;
            event.doubleValue = 313;
            event.clazz = HashMap.class;
            event.characater = '&';
            event.byteValue = (byte) 123;
            event.longValue = 1234567890L;
            event.shortValue = 64;
            event.booleanValue = false;
            event.commit();
            recording.stop();
            List<RecordedEvent> events = Events.fromRecording(recording);
            Events.hasEvents(events);
            RecordedEvent e = events.get(0);
            String toString = e.toString();
            System.out.println(toString);
            Asserts.assertTrue(toString.contains("hello, world"), "Missing String field value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("4711"), "Missing integer fields value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("313"), "Missing double value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("HashMap"), "Missing class value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("1234567890"), "Missing long value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("&"), "Missing char value in RecordedEvent#toSting()");
            Asserts.assertTrue(toString.contains("123"), "Missing byte value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("64"), "Missing short value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("false"), "Missing boolean value in RecordedEvent#toString()");
            Asserts.assertTrue(toString.contains("HelloWorldEvent"), "Missing class name in RecordedEvent#toString()");
        }
    }
 
Example 6
Source File: ProfileResults.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/** true if we care about this event */
static boolean isInteresting(String mode, RecordedEvent event) {
  String name = event.getEventType().getName();
  switch(mode) {
    case "cpu":
      return (name.equals("jdk.ExecutionSample") || name.equals("jdk.NativeMethodSample")) &&
          !isGradlePollThread(event.getThread("sampledThread"));
    case "heap":
      return (name.equals("jdk.ObjectAllocationInNewTLAB") || name.equals("jdk.ObjectAllocationOutsideTLAB")) &&
          !isGradlePollThread(event.getThread("eventThread"));
    default:
      throw new UnsupportedOperationException(event.toString());
  }
}
 
Example 7
Source File: ProfileResults.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/** value we accumulate for this event */
static long getValue(RecordedEvent event) {
  switch(event.getEventType().getName()) {
    case "jdk.ObjectAllocationInNewTLAB":
      return event.getLong("tlabSize");
    case "jdk.ObjectAllocationOutsideTLAB":
      return event.getLong("allocationSize");
    case "jdk.ExecutionSample":
      return 1L;
    case "jdk.NativeMethodSample":
      return 1L;
    default:
      throw new UnsupportedOperationException(event.toString());
  }
}