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;
|
||||
|
||||
// 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;
|
||||
|
|
Loading…
Reference in a new issue