Refactor time measurement code

This commit is contained in:
Manuel Thalmann 2022-12-05 22:24:01 +01:00
parent e885c492ad
commit 3efdc088fc

View file

@ -123,11 +123,17 @@ public class SortServer implements CommandExecutor {
long endTime = startTime;
// TODO Implement Aufgabe 1 und 2 (Tipp: siehe Consumer für Aufruf von
sorter.accept(a);
endTime = System.currentTimeMillis();
int count = 0;
while (endTime < startTime + 1000) {
System.arraycopy(a, 0, b, 0, dataElems);
sorter.accept(b);
count++;
endTime = System.currentTimeMillis();
}
// Sortiermethode)
elapsed = (double) (endTime - startTime);
elapsed = (double) ((endTime - startTime) / count);
if (!isSorted(b))
throw new Exception("ERROR not sorted");
return elapsed;