xref: /original-bsd/old/refer/hunt/tick.c (revision 42c7e7a1)
1 /*-
2  * %sccs.include.proprietary.c%
3  */
4 
5 #ifndef lint
6 static char sccsid[] = "@(#)tick.c	4.4 (Berkeley) 04/18/91";
7 #endif /* not lint */
8 
9 /* time programs */
10 # include <stdio.h>
11 # include <sys/types.h>
12 # include <sys/timeb.h>
13 struct tbuffer {
14 	long	proc_user_time;
15 	long	proc_system_time;
16 	long	child_user_time;
17 	long	child_system_time;
18 };
19 static long start, user, system;
20 tick()
21 {
22 	struct tbuffer tx;
23 	struct timeb tp;
24 	times (&tx);
25 	ftime (&tp);
26 	user =  tx.proc_user_time;
27 	system= tx.proc_system_time;
28 	start = tp.time*1000+tp.millitm;
29 }
30 tock()
31 {
32 	struct tbuffer tx;
33 	struct timeb tp;
34 	float lap, use, sys;
35 	if (start==0) return;
36 	times (&tx);
37 	ftime (&tp);
38 	lap = (tp.time*1000+tp.millitm-start)/1000.;
39 	use = (tx.proc_user_time - user)/60.;
40 	sys = (tx.proc_system_time - system)/60.;
41 	printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n",
42 		lap, use+sys, use, sys);
43 }
44