Commit 36157524 authored by Sven Woltmann's avatar Sven Woltmann

Count local variable assignments in Selection Sort

parent bd3ecc84
......@@ -13,6 +13,7 @@ public class Counters {
private long comparisons;
private long reads;
private long writes;
private long localVariableAssignments;
public void incIterations() {
iterations++;
......@@ -56,15 +57,20 @@ public class Counters {
writes += x;
}
public void addLocalVariableAssignments(int x) {
localVariableAssignments += x;
}
@Override
public String toString() {
return String.format(Locale.US,
"iterations = %,11d, comparisons = %,11d, " +
"reads = %,11d, writes = %,11d",
"reads = %,11d, writes = %,11d, var.assignments = %,11d",
iterations,
comparisons,
reads,
writes);
writes,
localVariableAssignments);
}
}
......@@ -52,6 +52,7 @@ public class SelectionSort implements SortAlgorithm {
if (numAtJ < min) {
minPos = j;
min = numAtJ;
counters.addLocalVariableAssignments(2);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment