Skip to content

Commit

Permalink
Add probe distance
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-bell committed Dec 15, 2024
1 parent 0a91f92 commit 46f1141
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/eval-1h-20x-log-distance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Eval 1h-20x
name: Eval 1h-20x with distance log
on: workflow_dispatch
jobs:
evaluate:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/eval-24h-5x-log-distance.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Thin evaluation - 24 hours, 5 trials
name: Thin evaluation - 24 hours, 5 trials with distance log
on: workflow_dispatch
jobs:
evaluate:
Expand Down
28 changes: 26 additions & 2 deletions fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestGuidance.java
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,10 @@ private int getLevenshteinDistFromString(String s1, String s2) {

private void logMutation(boolean saved) {
String parentRaw =savedInputs.get(currentParentInputIdx).raw;
String text = "";
if (currentRaw != null && parentRaw != null) {
int distance = getLevenshteinDistFromString(currentRaw, parentRaw);
String text = currentRaw.length() + "," + parentRaw.length() + "," +
text = currentRaw.length() + "," + parentRaw.length() + "," +
distance + "," + saved + "," + currentParentInputIdx + ",";
if (saved) {
text += Integer.toString(currentInput.id);
Expand All @@ -822,8 +823,31 @@ private void logMutation(boolean saved) {
} else {
text += "-1";
}
appendLineToFile(mutationLog, text);
} else {
text = "-1,-1,-1," + saved + "," + currentParentInputIdx + ",-1,";
}
if(currentInput.coverage != null) {
//Also calculate number of probes shared between the two inputs
int sharedProbes = 0;
IntHashSet currentProbes = new IntHashSet();
currentProbes.addAll(currentInput.coverage.getCovered());
IntHashSet parentProbes = new IntHashSet();
parentProbes.addAll(savedInputs.get(currentParentInputIdx).coverage.getCovered());
IntIterator currentProbesIterator = currentProbes.intIterator();
while (currentProbesIterator.hasNext()) {
int probe = currentProbesIterator.next();
if (parentProbes.contains(probe)) {
sharedProbes++;
}
}
// Calculate the total number of probes covered by the two inputs
int totalProbes = currentProbes.size() + parentProbes.size() - sharedProbes;
text += "," + sharedProbes + "," + currentProbes.size() + "," + parentProbes.size() + "," + totalProbes;
}
else {
text += ",,,";
}
appendLineToFile(mutationLog, text);
}

@Override
Expand Down

0 comments on commit 46f1141

Please sign in to comment.