Search in sources :

Example 1 with StackFrame

use of com.insightfullogic.honest_profiler.core.parser.StackFrame in project honest-profiler by jvm-profiling-tools.

the class LogCollectorTest method logCollectorShouldCopeWithUnexpectedFrames.

@Test
public void logCollectorShouldCopeWithUnexpectedFrames() {
    final Deque<Profile> found = new ArrayDeque<>();
    final LogCollector collector = new LogCollector(found::add, true);
    for (int i = 0; i < 10; i++) {
        collector.handle(new Method(i, "a", "Bass", "c" + i));
    }
    assertTrue("methods don't cause profiles", found.isEmpty());
    int threadId = 0;
    collector.handle(new TraceStart(2, ++threadId, 1, 1));
    assertTrue("nothing to profile still", found.isEmpty());
    collector.handle(new StackFrame(LINE, 0));
    collector.handle(new StackFrame(LINE, 1));
    // ..and one unexpected frame
    collector.handle(new StackFrame(LINE, 2));
    // normal method afterwards
    collector.handle(new TraceStart(2, ++threadId, 1, 1));
    collector.handle(new StackFrame(LINE, 6));
    collector.handle(new StackFrame(LINE, 7));
    // and continuation
    collector.handle(new TraceStart(20, ++threadId, 1, 1));
    assertArrayEquals(new long[] { 2, 7 }, idOfLastMethodInEachThread(found.getLast()));
}
Also used : TraceStart(com.insightfullogic.honest_profiler.core.parser.TraceStart) StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame) Method(com.insightfullogic.honest_profiler.core.parser.Method) Profile(com.insightfullogic.honest_profiler.core.profiles.Profile) ArrayDeque(java.util.ArrayDeque) Test(org.junit.Test)

Example 2 with StackFrame

use of com.insightfullogic.honest_profiler.core.parser.StackFrame in project honest-profiler by jvm-profiling-tools.

the class AggregationUtil method keysFor.

// -> List of parents identifying a Tree node in a Tree with Thread root nodes
public static final String[] keysFor(ThreadGrouping threadGrouping, FrameGrouping frameGrouping, ThreadMeta thread, StackFrame... frames) {
    String[] result = new String[frames.length + 1];
    result[0] = keyFor(threadGrouping, thread);
    int idx = 1;
    for (StackFrame frame : frames) {
        result[idx++] = keyFor(frameGrouping, frame);
    }
    return result;
}
Also used : StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame)

Example 3 with StackFrame

use of com.insightfullogic.honest_profiler.core.parser.StackFrame in project honest-profiler by jvm-profiling-tools.

the class AggregationUtil method keysFor.

// -> List of parents identifying a Tree node in a Tree with non-Thread root nodes
public static final String[] keysFor(FrameGrouping frameGrouping, StackFrame... frames) {
    String[] result = new String[frames.length];
    int idx = 0;
    for (StackFrame frame : frames) {
        result[idx++] = keyFor(frameGrouping, frame);
    }
    return result;
}
Also used : StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame)

Example 4 with StackFrame

use of com.insightfullogic.honest_profiler.core.parser.StackFrame in project honest-profiler by jvm-profiling-tools.

the class FlatProfileTest method calculateMajorityFlatProfiles.

@Test
public void calculateMajorityFlatProfiles() {
    TraceStart startTrace = new TraceStart(1, 1, 1, 1);
    collector.handle(startTrace);
    collector.handle(new StackFrame(20, 5));
    collector.handle(ProfileFixtures.println);
    collector.handle(startTrace);
    collector.handle(new StackFrame(20, 5));
    collector.handle(startTrace);
    collector.handle(new StackFrame(25, 6));
    collector.handle(ProfileFixtures.append);
    collector.endOfLog();
    Profile profile = listener.getProfile();
    assertEquals(3, profile.getTraceCount());
    assertEquals(2L, profile.flatByMethodProfile().count());
    assertEntry(ProfileFixtures.println, 2.0 / 3, profile.flatByMethodProfile().findFirst());
    assertEntry(ProfileFixtures.append, 1.0 / 3, profile.flatByMethodProfile().filter(e -> e.getTotalTimeShare() < 0.5).findFirst());
}
Also used : TraceStart(com.insightfullogic.honest_profiler.core.parser.TraceStart) StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame) Profile(com.insightfullogic.honest_profiler.core.profiles.Profile) Test(org.junit.Test)

Example 5 with StackFrame

use of com.insightfullogic.honest_profiler.core.parser.StackFrame in project honest-profiler by jvm-profiling-tools.

the class FlatProfileTest method looksUpMethodNames.

@Test
public void looksUpMethodNames() {
    collector.handle(new TraceStart(1, 1, 1, 1));
    collector.handle(new StackFrame(20, 5));
    collector.handle(ProfileFixtures.println);
    collector.endOfLog();
    Profile profile = listener.getProfile();
    assertEquals(1, profile.getTraceCount());
    assertEquals(1L, profile.flatByMethodProfile().count());
    assertEntry(ProfileFixtures.println, 1.0, profile.flatByMethodProfile().findFirst());
}
Also used : TraceStart(com.insightfullogic.honest_profiler.core.parser.TraceStart) StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame) Profile(com.insightfullogic.honest_profiler.core.profiles.Profile) Test(org.junit.Test)

Aggregations

StackFrame (com.insightfullogic.honest_profiler.core.parser.StackFrame)12 TraceStart (com.insightfullogic.honest_profiler.core.parser.TraceStart)7 Method (com.insightfullogic.honest_profiler.core.parser.Method)5 Test (org.junit.Test)4 ThreadMeta (com.insightfullogic.honest_profiler.core.parser.ThreadMeta)3 Profile (com.insightfullogic.honest_profiler.core.profiles.Profile)3 LeanNode (com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)2 LeanProfile (com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile)2 FrameInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.FrameInfo)2 MethodInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.MethodInfo)2 NumericInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.NumericInfo)2 ThreadInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.ThreadInfo)2 LeanLogCollectorDriver (com.insightfullogic.honest_profiler.framework.LeanLogCollectorDriver)2 BigInteger (java.math.BigInteger)2 Arrays.asList (java.util.Arrays.asList)2 Collections.reverse (java.util.Collections.reverse)2 List (java.util.List)2 Optional (java.util.Optional)2 Assert.assertEquals (org.junit.Assert.assertEquals)2 Assert.assertNotNull (org.junit.Assert.assertNotNull)2