Refactor time measurement code
This commit is contained in:
parent
e885c492ad
commit
3efdc088fc
1 changed files with 9 additions and 3 deletions
|
@ -123,11 +123,17 @@ public class SortServer implements CommandExecutor {
|
||||||
long endTime = startTime;
|
long endTime = startTime;
|
||||||
|
|
||||||
// TODO Implement Aufgabe 1 und 2 (Tipp: siehe Consumer für Aufruf von
|
// TODO Implement Aufgabe 1 und 2 (Tipp: siehe Consumer für Aufruf von
|
||||||
sorter.accept(a);
|
int count = 0;
|
||||||
endTime = System.currentTimeMillis();
|
|
||||||
|
while (endTime < startTime + 1000) {
|
||||||
|
System.arraycopy(a, 0, b, 0, dataElems);
|
||||||
|
sorter.accept(b);
|
||||||
|
count++;
|
||||||
|
endTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
// Sortiermethode)
|
// Sortiermethode)
|
||||||
|
|
||||||
elapsed = (double) (endTime - startTime);
|
elapsed = (double) ((endTime - startTime) / count);
|
||||||
if (!isSorted(b))
|
if (!isSorted(b))
|
||||||
throw new Exception("ERROR not sorted");
|
throw new Exception("ERROR not sorted");
|
||||||
return elapsed;
|
return elapsed;
|
||||||
|
|
Loading…
Reference in a new issue