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