Ignore machine-check MSRs
[freebsd-src/fkvm-freebsd.git] / contrib / traceroute / median.awk
blob5935bad4ff4bb316ef6405f56d13c218e8339723
1 /^ *[0-9]/ {
2 # print out the median time to each hop along a route.
3 tottime = 0; n = 0;
4 for (f = 5; f <= NF; ++f) {
5 if ($f == "ms") {
6 ++n
7 time[n] = $(f - 1)
10 if (n > 0) {
11 # insertion sort the times to find the median
12 for (i = 2; i <= n; ++i) {
13 v = time[i]; j = i - 1;
14 while (time[j] > v) {
15 time[j+1] = time[j];
16 j = j - 1;
17 if (j < 0)
18 break;
20 time[j+1] = v;
22 if (n > 1 && (n % 2) == 0)
23 median = (time[n/2] + time[(n/2) + 1]) / 2
24 else
25 median = time[(n+1)/2]
27 print $1, median