8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / refer / tick.c
blobefa94aef5fd501a5129b116e9913c48cef44d686
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* time programs */
18 #include <stdio.h>
19 #include <sys/types.h>
21 struct tbuffer {
22 long proc_user_time;
23 long proc_system_time;
24 long child_user_time;
25 long child_system_time;
27 static long start, user, systm;
29 void
30 tick(void)
32 struct tbuffer tx;
33 time_t tp;
34 times(&tx);
35 time(&tp);
36 user = tx.proc_user_time;
37 systm = tx.proc_system_time;
38 start = tp;
41 void
42 tock(void)
44 struct tbuffer tx;
45 time_t tp;
46 float lap, use, sys;
47 if (start == 0)
48 return;
49 times(&tx);
50 time(&tp);
51 lap = (tp - start)/60.;
52 use = (tx.proc_user_time - user)/60.;
53 sys = (tx.proc_system_time - systm)/60.;
54 printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n",
55 lap, use+sys, use, sys);