use of org.spf4j.base.avro.Method in project spf4j by zolyfarkas.
the class SampleNode method addToSampleNode.
public static void addToSampleNode(final SampleNode node, final StackTraceElement... stackTrace) {
SampleNode prevResult = node;
prevResult.sampleCount++;
for (int i = stackTrace.length - 1; i >= 0; i--) {
StackTraceElement elem = stackTrace[i];
final Method method = Methods.getMethod(elem);
SampleNode nNode = prevResult.get(method);
if (nNode != null) {
nNode.sampleCount++;
} else {
nNode = new SampleNode(1);
prevResult.put(method, nNode);
}
prevResult = nNode;
}
}
use of org.spf4j.base.avro.Method in project spf4j by zolyfarkas.
the class SampleNode method traverse.
public static void traverse(final Method m, final SampleNode node, final Invocation handler, final Function<Deque, TraversalData> func) {
Deque<TraversalData> dq = new ArrayDeque<>();
dq.add(new TraversalData(m, node));
TraversalData t;
while ((t = func.apply(dq)) != null) {
if (!t.n.isEmpty()) {
Method from = t.m;
boolean conti = t.n.forEachEntry(new TObjectObjectProcedure<Method, SampleNode>() {
@Override
public boolean execute(final Method a, final SampleNode b) {
boolean result = handler.invocation(from, a, b.sampleCount);
if (result) {
dq.addLast(new TraversalData(a, b));
}
return result;
}
});
if (!conti) {
return;
}
}
}
}
use of org.spf4j.base.avro.Method in project spf4j by zolyfarkas.
the class SampleGraphTest method testAggLogic.
@Test
public void testAggLogic() throws IOException {
SampleNode samples = org.spf4j.ssdump2.Converter.load(Resources.getResource("org.spf4j.concurrent.ThreadPoolBenchmark.spfLifoTpBenchmark-Throughput_m4.ssdump2").openStream());
Method method = Methods.getMethod("org.spf4j.concurrent.LifoThreadPoolExecutorSQP$QueuedThread", "doRun");
AtomicInteger ai = new AtomicInteger();
SampleNode.traverse(Methods.ROOT, samples, (f, t, s) -> {
if (f.equals(method)) {
LOG.debug("from = {}, to = {}, samples = {}", f, t, s);
ai.getAndIncrement();
}
return true;
});
SampleGraph sg = new SampleGraph(Methods.ROOT, samples);
SampleGraph.SampleKey sampleKey = new SampleGraph.SampleKey(method, 0);
SampleGraph.AggSample aggNode = sg.getAggNode(sampleKey);
Set<SampleGraph.AggSample> children = sg.getChildren(aggNode);
LOG.debug("parent = {}, children = {}", aggNode, children);
Assert.assertEquals(ai.get(), children.size());
}
use of org.spf4j.base.avro.Method in project spf4j by zolyfarkas.
the class FlameStackPanel method filter.
@Override
public void filter() {
List<Pair<Method, SampleNode>> tips = search(xx, yy, 0, 0);
if (tips.size() >= 1) {
final Method value = tips.get(0).getFirst();
updateSamples(getMethod(), getSamples().filteredBy(new EqualsPredicate<Method>(value)));
repaint();
}
}
use of org.spf4j.base.avro.Method in project spf4j by zolyfarkas.
the class FlameStackPanel method paintNode.
@SuppressFBWarnings("ISB_TOSTRING_APPENDING")
private int paintNode(final Method method, final SampleNode node, final Graphics2D g2, final int x, final int py, final int width, final int height, final int depth) {
if (node == null) {
return 0;
}
int y = py;
int sampleCount = node.getSampleCount();
String val = Methods.toString(method) + '-' + sampleCount;
setElementColor(depth, g2);
g2.setClip(x, y, width, height);
g2.fillRect(x, y, width, height);
insert(x, y, width, height, Pair.of(method, node));
g2.setPaint(Color.BLACK);
g2.drawString(val, x, y + height - 1);
g2.setClip(null);
g2.setPaint(LINK_COLOR);
g2.drawRect(x, y, width, height);
int result = height;
if (!node.isEmpty()) {
y += height;
int relX = x;
double scale = (double) width / sampleCount;
int maxY = 0;
for (Map.Entry<Method, SampleNode> entry : node.entrySet()) {
SampleNode cnode = entry.getValue();
// sampleCount -> width
// childSampleCount -> childWidth
int childWidth = (int) (scale * cnode.getSampleCount());
if (childWidth > 0) {
maxY = Math.max(maxY, paintNode(entry.getKey(), cnode, g2, relX, y, childWidth, height, depth + 1));
relX += childWidth;
}
}
result += maxY;
}
return result;
}
Aggregations