Remove building with NOCRYPTO option
[minix.git] / usr.sbin / traceroute / median.awk
blob672e1150ecf1221d9ad7134f0459610a1da713e7
1 #!/bin/awk -f
2 # $NetBSD: median.awk,v 1.5 1997/10/04 16:31:32 christos Exp $
3 /^ *[0-9]/ {
4 # print out the median time to each hop along a route.
5 tottime = 0; n = 0;
6 for (f = 5; f <= NF; ++f) {
7 if ($f == "ms") {
8 ++n
9 time[n] = $(f - 1)
12 if (n > 0) {
13 # insertion sort the times to find the median
14 for (i = 2; i <= n; ++i) {
15 v = time[i]; j = i - 1;
16 while (time[j] > v) {
17 time[j+1] = time[j];
18 j = j - 1;
19 if (j < 0)
20 break;
22 time[j+1] = v;
24 if (n > 1 && (n % 2) == 0)
25 median = (time[n/2] + time[(n/2) + 1]) / 2
26 else
27 median = time[(n+1)/2]
29 print $1, median