ANSIfication; bug report 4.3BSD/bin/223
[unix-history] / usr / src / old / refer / hunt / tick.c
CommitLineData
476fcd16
SL
1#ifndef lint
2static char sccsid[] = "@(#)tick.c 4.2 (Berkeley) %G%";
3#endif
4
8f9ace89
GL
5/* time programs */
6# include "stdio.h"
7# include "sys/types.h"
8# include "sys/timeb.h"
9struct tbuffer {
10 long proc_user_time;
11 long proc_system_time;
12 long child_user_time;
13 long child_system_time;
14};
15static long start, user, system;
16tick()
17{
18 struct tbuffer tx;
19 struct timeb tp;
20 times (&tx);
21 ftime (&tp);
22 user = tx.proc_user_time;
23 system= tx.proc_system_time;
24 start = tp.time*1000+tp.millitm;
25}
26tock()
27{
28 struct tbuffer tx;
29 struct timeb tp;
30 float lap, use, sys;
31 if (start==0) return;
32 times (&tx);
33 ftime (&tp);
34 lap = (tp.time*1000+tp.millitm-start)/1000.;
35 use = (tx.proc_user_time - user)/60.;
36 sys = (tx.proc_system_time - system)/60.;
37 printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n",
38 lap, use+sys, use, sys);
39}