Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / ntp / scripts / stats / loop.awk
blobbac90db8b9541638ca2753825acdde3fa39148c7
1 # awk program to scan loopstats files and report errors/statistics
3 # usage: awk -f loop.awk loopstats
5 # format of loopstats record
6 # MJD sec time (s) freq (ppm) poll
7 # 49235 3.943 0.000016 22.4716 6
9 # format of output dataset (time values in milliseconds, freq in ppm)
10 # loopstats.19960706
11 # loop 1180, 0+/-11.0, rms 2.3, freq -24.45+/-0.045, var 0.019
13 BEGIN {
14 loop_tmax = loop_fmax = -1e9
15 loop_tmin = loop_fmin = 1e9
18 # scan all records in file
21 if (NF >= 5) {
22 loop_count++
23 if ($3 > loop_tmax)
24 loop_tmax = $3
25 if ($3 < loop_tmin)
26 loop_tmin = $3
27 if ($4 > loop_fmax)
28 loop_fmax = $4
29 if ($4 < loop_fmin)
30 loop_fmin = $4
31 loop_time += $3
32 loop_time_rms += $3 * $3
33 loop_freq += $4
34 loop_freq_rms += $4 * $4
36 } END {
37 if (loop_count > 0) {
38 loop_time /= loop_count
39 loop_time_rms = sqrt(loop_time_rms / loop_count - loop_time * loop_time)
40 loop_freq /= loop_count
41 loop_freq_rms = sqrt(loop_freq_rms / loop_count - loop_freq * loop_freq)
42 printf "loop %d, %.0f+/-%.1f, rms %.1f, freq %.2f+/-%0.3f, var %.3f\n", loop_count, (loop_tmax + loop_tmin) / 2 * 1e6, (loop_tmax - loop_tmin) / 2 * 1e6, loop_time_rms * 1e6, (loop_fmax + loop_fmin) / 2, (loop_fmax - loop_fmin) / 2, loop_freq_rms