Commit c10beb58feb8164bcf03014ecc04b45d3e448e5c

Authored by Paulo Graça
1 parent 6af8146dba
Exists in tests

PG: fix time counting

ptcrisync-test/src/main/java/pt/ptcris/test/dummy/ProgressHandlerDummyImpl.java
... ... @@ -112,7 +112,7 @@ public class ProgressHandlerDummyImpl implements ProgressHandler {
112 112 Long[] data = timeEachExecution.toArray(new Long[0]);
113 113 // Finding the largest element
114 114 long max = (data[1]-data[0]);
115   - for (int i = 1; i < data.length-1; i++) {
  115 + for (int i = 2; i < data.length-1; i++) {
116 116 if ((data[i+1]-data[i]) > max) max = (data[i+1]-data[i]);
117 117 }
118 118 return max;
... ... @@ -122,11 +122,13 @@ public class ProgressHandlerDummyImpl implements ProgressHandler {
122 122 Long[] data = (Long[]) timeEachExecution.toArray(new Long[0]);
123 123 // calculate sum
124 124 long sum = 0;
125   - for (int i = 0; i < data.length-1; i++){
  125 + //It starts on 1 instead of 0 because 0 is the init process
  126 + //and if used it will influence the average result
  127 + for (int i = 1; i < data.length-1; i++){
126 128 sum = sum + (data[i+1]-data[i]);
127 129 }
128 130 // calculate average
129   - return (sum / (data.length-1));
  131 + return (sum / (data.length-2));
130 132  
131 133 }
132 134  
... ...