Revision 10405,
545 bytes
checked in by ghudson, 27 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r10404,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
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) |
---|
8 | } |
---|
9 | } |
---|
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; |
---|
19 | } |
---|
20 | time[j+1] = v; |
---|
21 | } |
---|
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] |
---|
26 | |
---|
27 | print $1, median |
---|
28 | } |
---|
29 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.