Skip to content

Commit

Permalink
More testing
Browse files Browse the repository at this point in the history
  • Loading branch information
PhRX committed Apr 19, 2017
1 parent f11d015 commit e073547
Show file tree
Hide file tree
Showing 6 changed files with 647 additions and 91 deletions.
@@ -1,5 +1,6 @@
package com.insightfullogic.honest_profiler.core; package com.insightfullogic.honest_profiler.core;


import static com.insightfullogic.honest_profiler.core.aggregation.AggregationUtil.nano;
import static com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping.combine; import static com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping.combine;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -47,7 +48,7 @@ public void accept(LeanProfile profile)


// Assertions // Assertions


public void assertSizeEquals(int size) public void assertAggregationSizeEquals(int size)
{ {
assertEquals("Wrong size of the Flat aggregation.", size, flat.getData().size()); assertEquals("Wrong size of the Flat aggregation.", size, flat.getData().size());
} }
Expand All @@ -67,4 +68,9 @@ public void assertContains(String key, int selfCount, int totalCount, long selfT
assertEquals("Wrong self time for entry " + key, selfTime, entry.getSelfTime()); assertEquals("Wrong self time for entry " + key, selfTime, entry.getSelfTime());
assertEquals("Wrong total time for entry " + key, totalTime, entry.getTotalTime()); assertEquals("Wrong total time for entry " + key, totalTime, entry.getTotalTime());
} }

public void assertContains(String key, int selfCount, int totalCount)
{
assertContains(key, selfCount, totalCount, nano(selfCount), nano(totalCount));
}
} }
Expand Up @@ -84,6 +84,7 @@ else if (event instanceof ThreadMeta)
}); });
} }



public void endOfLog() public void endOfLog()
{ {
collector.endOfLog(); collector.endOfLog();
Expand Down
Expand Up @@ -23,7 +23,7 @@ public class AggregationProfileTest
public void checkThreadInfoLogic() public void checkThreadInfoLogic()
{ {
LeanProfileGenerator gen = new LeanProfileGenerator(); LeanProfileGenerator gen = new LeanProfileGenerator();
LogEventFactory.applyScenario(gen); LogEventFactory.applyScenario09(gen);
LeanProfile leanProfile = gen.getProfile(); LeanProfile leanProfile = gen.getProfile();


// Check initial state of ThreadNode ThreadInfo // Check initial state of ThreadNode ThreadInfo
Expand All @@ -50,13 +50,13 @@ public void checkThreadInfoLogic()
public void checkGlobalAggregation() public void checkGlobalAggregation()
{ {
LeanProfileGenerator gen = new LeanProfileGenerator(); LeanProfileGenerator gen = new LeanProfileGenerator();
LogEventFactory.applyScenario(gen); LogEventFactory.applyScenario09(gen);
AggregationProfile profile = new AggregationProfile(gen.getProfile()); AggregationProfile profile = new AggregationProfile(gen.getProfile());
NumericInfo global = profile.getGlobalData(); NumericInfo global = profile.getGlobalData();


assertEquals("Global Self Count should be 0", 0, global.getSelfCnt()); assertEquals("Global Self Count should be 0", 0, global.getSelfCnt());
assertEquals("Global Total Count wrong", 53, global.getTotalCnt()); assertEquals("Global Total Count wrong", 91, global.getTotalCnt());
assertEquals("Global Self Time should be 0", ZERO, global.getSelfTime()); assertEquals("Global Self Time should be 0", ZERO, global.getSelfTime());
assertEquals("Global Total Time wrong", valueOf(nano(53)), global.getTotalTime()); assertEquals("Global Total Time wrong", valueOf(nano(91)), global.getTotalTime());
} }
} }
Expand Up @@ -3,6 +3,7 @@
import static java.util.concurrent.TimeUnit.SECONDS; import static java.util.concurrent.TimeUnit.SECONDS;


import com.insightfullogic.honest_profiler.core.parser.Method; import com.insightfullogic.honest_profiler.core.parser.Method;
import com.insightfullogic.honest_profiler.core.parser.StackFrame;


public class AggregationUtil public class AggregationUtil
{ {
Expand All @@ -19,17 +20,17 @@ public static final String getFqmn(Method method)
return result.toString(); return result.toString();
} }


public static final String getFqmnPlusBci(Method method) public static final String getFqmnPlusBci(Method method, StackFrame frame)
{ {
StringBuilder result = new StringBuilder(getFqmn(method)); StringBuilder result = new StringBuilder(getFqmn(method));
result.append(":").append(method.getBci()); result.append(":").append(frame.getBci());
return result.toString(); return result.toString();
} }


public static final String getFqmnPlusLineNr(Method method) public static final String getFqmnPlusLineNr(Method method, StackFrame frame)
{ {
StringBuilder result = new StringBuilder(getFqmn(method)); StringBuilder result = new StringBuilder(getFqmn(method));
result.append(":").append(method.getLine()); result.append(":").append(frame.getLineNumber());
return result.toString(); return result.toString();
} }


Expand Down

0 comments on commit e073547

Please sign in to comment.