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()));
}
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());
}
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());
}
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));
}
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);
}
Aggregations