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