I'm not sure why this is happening, every time when I get to 10 in the timer the numbers start going negative. Heres the code:
@Test
void testTimeSortCompator() {
System.out.println("Time to find largest sort comparator:");
for (int i = 0; i < inputArraySizes.length; i++) {
int total = 0;
for (int j = 0; j < numRunsToAverage; j++) {
list = (List<Integer>) createList(inputArraySizes[i]);
total += doSortComparator();
}
System.out.println(inputArraySizes[i] + " " + (total / numRunsToAverage));
}
}
private long doSortComparator() {
int temp = (int) Math.floor((Math.random() * (100 - 1) + 1));
long start = System.nanoTime();
FindKLargest.findKLargestSort(list, temp, intComparator);
long stop = System.nanoTime();
long duration = (stop - start);
return duration;
}
enter image descrienter code hereption here
Aucun commentaire:
Enregistrer un commentaire