Skip to content

Commit

Permalink
Fix measurements not added to last level bug
Browse files Browse the repository at this point in the history
  • Loading branch information
terahidro2003 committed Jan 29, 2025
1 parent f8ff7a4 commit 4cce1c0
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static CallTreeNode convertCallContextTreeToCallTree(StackTraceTreeNode c
methodNameWithNew,
mConfig);
} else {
createPeassNode(currentBAT, ctn, commit, predecessor, vms);
createPeassNode(currentBAT, ctn, commit, predecessor, vms, false);
ctn = ctn.getChildByKiekerPattern(currentBAT.getPayload().getMethodName() + "()");
}

Expand All @@ -41,6 +41,9 @@ public static CallTreeNode convertCallContextTreeToCallTree(StackTraceTreeNode c
}

List<StackTraceTreeNode> children = currentBAT.getChildren();
if (children.isEmpty()) {
createPeassNode(currentBAT, ctn, commit, predecessor, vms, true);
}
for (StackTraceTreeNode child : children) {
convertCallContextTreeToCallTree(child, predecessorBAT, ctn, commit, predecessor, vms);
}
Expand Down Expand Up @@ -85,11 +88,33 @@ public static StackTraceTreeNode search(StackTraceTreeNode searchable, StackTrac
return null;
}

private static void createPeassNode(StackTraceTreeNode node, CallTreeNode peassNode, String commit, String oldCommit, int vms) {
private static void createPeassNode(StackTraceTreeNode node, CallTreeNode peassNode, String commit,
String oldCommit, int vms, boolean lastNode) {
peassNode.initCommitData();

addMeasurements(commit, node, peassNode, vms);

if(!lastNode) appendChild(node, peassNode);

peassNode.createStatistics(commit);
}

public static String getCorrectCallString(String method) {
int lastParenthesisIndex = method.contains("(") ? method.lastIndexOf("(") : method.length() -1;
String methodName = method.substring(0, lastParenthesisIndex);

String[] parts = methodName.split(" ");
String methodNameWithoutType = parts.length > 1 ? parts[parts.length - 1] : method;

int lastDotIndex = methodNameWithoutType.contains(".") ? methodNameWithoutType.lastIndexOf(".")
: -1;
String className = lastDotIndex > 0 ? methodNameWithoutType.substring(0, lastDotIndex) : "";
methodName = methodNameWithoutType.substring(lastDotIndex + 1);

return className + "#" + methodName;
}

private static void appendChild(StackTraceTreeNode node, CallTreeNode peassNode) {
// check is done as a workaround for Peass kieker pattern check
if(node.getPayload().getMethodName().contains("<init>")) {
String methodNameWithNew = "new " + node.getPayload().getMethodName() + "()";
Expand All @@ -103,8 +128,6 @@ private static void createPeassNode(StackTraceTreeNode node, CallTreeNode peassN
node.getPayload().getMethodName() + "()"
);
}

peassNode.createStatistics(commit);
}

private static void addMeasurements(String commit, StackTraceTreeNode node, CallTreeNode peassNode, int vms) {
Expand Down Expand Up @@ -145,12 +168,14 @@ public static CallTreeNode createOtherNodeRecursive(StackTraceTreeNode otherNode
methodNameWithNew,
mConfig);
} else {
createPeassNode(otherNode, otherCallTreeNode, predecessor, commit, vms);
createPeassNode(otherNode, otherCallTreeNode, predecessor, commit, vms, false);
otherCallTreeNode = otherCallTreeNode.getChildByKiekerPattern(otherNode.getPayload().getMethodName() + "()");
// otherCallTreeNode.createStatistics(predecessor);
}

List<StackTraceTreeNode> children = otherNode.getChildren();
if (children.isEmpty()) {
createPeassNode(otherNode, otherCallTreeNode, predecessor, commit, vms, true);
}
for (StackTraceTreeNode child : children) {
createOtherNodeRecursive(child, otherCallTreeNode , vms, predecessor, commit);
}
Expand Down

0 comments on commit 4cce1c0

Please sign in to comment.