Search in sources :

Example 1 with TraceStart

use of com.insightfullogic.honest_profiler.core.parser.TraceStart 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 TraceStart

use of com.insightfullogic.honest_profiler.core.parser.TraceStart 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 3 with TraceStart

use of com.insightfullogic.honest_profiler.core.parser.TraceStart 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)

Example 4 with TraceStart

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

the class ProfileTreeTest method printlnCallingPrintf.

private void printlnCallingPrintf(final int threadId) {
    collector.handle(new TraceStart(2, threadId, 0, 0));
    collector.handle(new StackFrame(20, ProfileFixtures.printfId));
    collector.handle(ProfileFixtures.printf);
    collector.handle(new StackFrame(20, ProfileFixtures.printlnId));
}
Also used : TraceStart(com.insightfullogic.honest_profiler.core.parser.TraceStart) StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame)

Example 5 with TraceStart

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

the class ProfileTreeTest method printlnCallingAppend.

private void printlnCallingAppend(int threadId) {
    collector.handle(new TraceStart(2, threadId, 0, 0));
    collector.handle(new StackFrame(20, ProfileFixtures.appendId));
    collector.handle(ProfileFixtures.append);
    collector.handle(new StackFrame(20, ProfileFixtures.printlnId));
    collector.handle(ProfileFixtures.println);
}
Also used : TraceStart(com.insightfullogic.honest_profiler.core.parser.TraceStart) StackFrame(com.insightfullogic.honest_profiler.core.parser.StackFrame)

Aggregations

StackFrame (com.insightfullogic.honest_profiler.core.parser.StackFrame)7 TraceStart (com.insightfullogic.honest_profiler.core.parser.TraceStart)7 Test (org.junit.Test)4 Profile (com.insightfullogic.honest_profiler.core.profiles.Profile)3 Method (com.insightfullogic.honest_profiler.core.parser.Method)2 Monitor (com.insightfullogic.honest_profiler.core.Monitor)1 LogEventListener (com.insightfullogic.honest_profiler.core.parser.LogEventListener)1 ThreadMeta (com.insightfullogic.honest_profiler.core.parser.ThreadMeta)1 ProfileNode (com.insightfullogic.honest_profiler.core.profiles.ProfileNode)1 FileLogSource (com.insightfullogic.honest_profiler.ports.sources.FileLogSource)1 File (java.io.File)1 PrintStream (java.io.PrintStream)1 ArrayDeque (java.util.ArrayDeque)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1 Option (org.kohsuke.args4j.Option)1