1*48296Sbostic /*- 2*48296Sbostic * %sccs.include.proprietary.c% 3*48296Sbostic */ 4*48296Sbostic 514506Ssam #ifndef lint 6*48296Sbostic static char sccsid[] = "@(#)tick.c 4.4 (Berkeley) 04/18/91"; 7*48296Sbostic #endif /* not lint */ 814506Ssam 913239Sgarrison /* time programs */ 1037895Sbostic # include <stdio.h> 1137895Sbostic # include <sys/types.h> 1237895Sbostic # include <sys/timeb.h> 1313239Sgarrison struct tbuffer { 1413239Sgarrison long proc_user_time; 1513239Sgarrison long proc_system_time; 1613239Sgarrison long child_user_time; 1713239Sgarrison long child_system_time; 1813239Sgarrison }; 1913239Sgarrison static long start, user, system; tick()2013239Sgarrisontick() 2113239Sgarrison { 2213239Sgarrison struct tbuffer tx; 2313239Sgarrison struct timeb tp; 2413239Sgarrison times (&tx); 2513239Sgarrison ftime (&tp); 2613239Sgarrison user = tx.proc_user_time; 2713239Sgarrison system= tx.proc_system_time; 2813239Sgarrison start = tp.time*1000+tp.millitm; 2913239Sgarrison } tock()3013239Sgarrisontock() 3113239Sgarrison { 3213239Sgarrison struct tbuffer tx; 3313239Sgarrison struct timeb tp; 3413239Sgarrison float lap, use, sys; 3513239Sgarrison if (start==0) return; 3613239Sgarrison times (&tx); 3713239Sgarrison ftime (&tp); 3813239Sgarrison lap = (tp.time*1000+tp.millitm-start)/1000.; 3913239Sgarrison use = (tx.proc_user_time - user)/60.; 4013239Sgarrison sys = (tx.proc_system_time - system)/60.; 4113239Sgarrison printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n", 4213239Sgarrison lap, use+sys, use, sys); 4313239Sgarrison } 44