Annotation of 42BSD/usr.bin/refer/tick.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)tick.c     4.2 (Berkeley) 8/11/83";
                      3: #endif
                      4: 
                      5: /* time programs */
                      6: # include "stdio.h"
                      7: # include "sys/types.h"
                      8: # include "sys/timeb.h"
                      9: struct tbuffer {
                     10:        long    proc_user_time;
                     11:        long    proc_system_time;
                     12:        long    child_user_time;
                     13:        long    child_system_time;
                     14: };
                     15: static long start, user, system;
                     16: tick()
                     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: }
                     26: tock()
                     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: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.