xref: /freebsd/contrib/one-true-awk/testdir/ctimes (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1awk '
2BEGIN {
3	OFS = "\t"
4	print "     new      old   new/old"
5	print ""
6}
7/differ/
8/:$/ {	name = $1; cnt = 0; next }
9$1 ~ /user|sys/ {
10	n = split($2, x, "m")	# 0m0.23s
11	if (n == 1)
12		time[cnt] += x[1]
13	else
14		time[cnt] += 60 * x[1] + x[2]
15}
16$1 ~ /sys/ {
17	cnt++
18	if (cnt == 2)
19		dump()
20}
21function dump() {
22	old = time[1]
23	new = time[0]
24	if (old > 0) {
25		printf "%8.2f %8.2f %8.3f  %s\n", new, old, new/old, name
26		rat += new/old
27	}
28	nrat++
29	totnew += new
30	totold += old
31	time[0] = time[1] = cnt = 0
32}
33END {
34	print ""
35	printf "%8.2f %8.2f\n\n", totnew, totold
36	printf "avg new/old   = %.3f\n", rat/nrat
37	printf "total new/old = %.3f\n", totnew/totold
38	print nrat " tests"
39}
40' $*
41