added code to count write operations used

This commit is contained in:
2020-06-02 13:31:55 -05:00
parent 2e8fa28a5a
commit 9597c56c5d
5 changed files with 15 additions and 5 deletions

View File

@@ -13,7 +13,7 @@ abstract class Sorter {
protected String sortType;
protected Integer[] numbers;
protected long comparisonsUsed = 0;
protected long wrtiesUsed=0;
protected long writesUsed=0;
public Sorter(String st, String filename){
sortType=st;
@@ -33,7 +33,7 @@ abstract class Sorter {
int tmp = numbers[a];
numbers[a] = numbers[b];
numbers[b] = tmp;
wrtiesUsed+=2;
writesUsed+=2;
}
int compare(int a, int b){
@@ -46,7 +46,7 @@ abstract class Sorter {
this.sort();
Instant end = Instant.now();
Duration time = Duration.between(start,end);
SortResult output = new SortResult(sortType, numbers, comparisonsUsed, time);
SortResult output = new SortResult(sortType, numbers, comparisonsUsed, writesUsed, time);
return output;
}