! To time a function call ! foo (a1,...) ! execute ! timeit (foo,a1,...) ! which executes the original call, discards the ! result, and returns the CPU time (in units of 10ms). ! Works for functions with up to five words of arguments ! ! See "man times" for more details. ! .section ".data" .align 4 tmsbuff: .skip 16 ! times writes results here .section ".text" .align 4 .global timeit timeit: save %sp,-96,%sp set tmsbuff,%l1 call times ! get "before" times mov %l1,%o0 ! d.s.: point to buffer ld [%l1],%l2 ! save "before" user time ld [%l1+4],%l3 ! save "before" system time mov %i1,%o0 ! copy arguments (whether really there or not) mov %i2,%o1 mov %i3,%o2 mov %i4,%o3 jmpl %i0,%o7 ! do underlying call mov %i5,%o4 ! d.s.: copy last argument call times ! get "after" times mov %l1,%o0 ! d.s.: point to buffer ld [%l1],%l4 ! get "after" user time ld [%l1+4],%l5 ! get "after" system time sub %l4,%l2,%l2 ! net user time sub %l5,%l3,%l3 ! net system time add %l2,%l3,%i0 ! net total time ret restore