Annotation of researchv8dc/cmd/refer/tick.c, revision 1.1.1.1

1.1       root        1: /* time programs */
                      2: # include "stdio.h"
                      3: # include "sys/types.h"
                      4: # include "sys/timeb.h"
                      5: struct tbuffer {
                      6:        long    proc_user_time;
                      7:        long    proc_system_time;
                      8:        long    child_user_time;
                      9:        long    child_system_time;
                     10: };
                     11: static long start, user, system;
                     12: tick()
                     13: {
                     14:        struct tbuffer tx;
                     15:        struct timeb tp;
                     16:        times (&tx);
                     17:        ftime (&tp);
                     18:        user =  tx.proc_user_time;
                     19:        system= tx.proc_system_time;
                     20:        start = tp.time*1000+tp.millitm;
                     21: }
                     22: tock()
                     23: {
                     24:        struct tbuffer tx;
                     25:        struct timeb tp;
                     26:        float lap, use, sys;
                     27:        if (start==0) return;
                     28:        times (&tx);
                     29:        ftime (&tp);
                     30:        lap = (tp.time*1000+tp.millitm-start)/1000.;
                     31:        use = (tx.proc_user_time - user)/60.;
                     32:        sys = (tx.proc_system_time - system)/60.;
                     33:        printf("Elapsed %.2f CPU %.2f (user %.2f, sys %.2f)\n",
                     34:                lap, use+sys, use, sys);
                     35: }

unix.superglobalmegacorp.com

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