added code to count write operations used
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user