|
24 | 24 | import java.util.concurrent.ConcurrentHashMap;
|
25 | 25 | import java.util.concurrent.CountDownLatch;
|
26 | 26 | import java.util.concurrent.TimeUnit;
|
| 27 | +import java.util.stream.Collectors; |
| 28 | + |
27 | 29 | import org.scion.jpan.*;
|
28 | 30 | import org.scion.jpan.internal.PathRawParser;
|
29 | 31 | import org.scion.multiping.util.*;
|
@@ -121,10 +123,32 @@ public static void main(String[] args) throws IOException {
|
121 | 123 | Result maxHops = results.stream().max(Comparator.comparingInt(Result::getHopCount)).get();
|
122 | 124 | Result maxPaths = results.stream().max(Comparator.comparingInt(Result::getPathCount)).get();
|
123 | 125 |
|
| 126 | + // avg/median: |
| 127 | + double avgPing = |
| 128 | + results.stream().filter(Result::isSuccess).mapToDouble(Result::getPingMs).average().orElse(-1); |
| 129 | + double avgHops = |
| 130 | + results.stream().filter(r -> r.getHopCount() > 0).mapToInt(Result::getHopCount).average().orElse(-1); |
| 131 | + double avgPaths = |
| 132 | + results.stream().filter(r -> r.getPathCount() > 0).mapToInt(Result::getPathCount).average().orElse(-1); |
| 133 | + List<Double> pings = results.stream().filter(Result::isSuccess).map(Result::getPingMs).sorted().collect(Collectors.toList()); |
| 134 | + double medianPing = pings.isEmpty() ? -1 : pings.get(pings.size() / 2); |
| 135 | + List<Integer> hops = results.stream().map(Result::getHopCount).filter(hopCount -> hopCount > 0).sorted().collect(Collectors.toList()); |
| 136 | + int medianHops = hops.isEmpty() ? -1 : hops.get(hops.size() / 2); |
| 137 | + List<Integer> paths = results.stream().map(Result::getPathCount).filter(pathCount -> pathCount > 0).sorted().collect(Collectors.toList()); |
| 138 | + int medianPaths = paths.isEmpty() ? -1 : paths.get(paths.size() / 2); |
| 139 | + |
124 | 140 | println("");
|
125 |
| - println("Max hops = " + maxHops.getHopCount() + ": " + maxHops); |
126 |
| - println("Max ping = " + round(maxPing.getPingMs(), 2) + "ms: " + maxPing); |
127 |
| - println("Max paths = " + maxPaths.getPathCount() + ": " + maxPaths); |
| 141 | + println("Max hops = " + maxHops.getHopCount() + ": " + maxHops); |
| 142 | + println("Max ping [ms] = " + round(maxPing.getPingMs(), 2) + ": " + maxPing); |
| 143 | + println("Max paths = " + maxPaths.getPathCount() + ": " + maxPaths); |
| 144 | + |
| 145 | + println("Median hops = " + medianHops); |
| 146 | + println("Median ping [ms] = " + round(medianPing, 2)); |
| 147 | + println("Median paths = " + medianPaths); |
| 148 | + |
| 149 | + println("Avg hops = " + round(avgHops, 1)); |
| 150 | + println("Avg ping [ms] = " + round(avgPing, 2)); |
| 151 | + println("Avg paths = " + (int) round(avgPaths, 0)); |
128 | 152 |
|
129 | 153 | println("");
|
130 | 154 | println("AS Stats:");
|
|
0 commit comments