Annotation of 42BSD/usr.lib/libU77/dtime_.c, revision 1.1

1.1     ! root        1: /*
        !             2: char id_dtime[] = "@(#)dtime_.c        1.1";
        !             3:  *
        !             4:  * Returns the delta time since the last call to dtime.
        !             5:  *
        !             6:  * calling sequence:
        !             7:  *     real time(2)
        !             8:  *     call dtime(time)
        !             9:  * where:
        !            10:  *     the 2 element array time will receive the user and system
        !            11:  *     elapsed time since the last call to dtime, or since the start
        !            12:  *     of execution.
        !            13:  *
        !            14:  * This routine can be called as function, and returns the sum of
        !            15:  * user and system times. The time_array argument must always be given.
        !            16:  *
        !            17:  * The resolution for all timing is 1/60 second.
        !            18:  */
        !            19: 
        !            20: #include <sys/types.h>
        !            21: #include <sys/times.h>
        !            22: 
        !            23: struct tb { float usrtime; float systime; };
        !            24: 
        !            25: time_t dutime=0, dstime=0;
        !            26: 
        !            27: float
        !            28: dtime_(dt) struct tb *dt;
        !            29: {      struct tms clock;
        !            30: 
        !            31:        times(&clock);
        !            32:        dt->usrtime = (float)(clock.tms_utime - dutime) / 60.0;
        !            33:        dt->systime = (float)(clock.tms_stime - dstime) / 60.0;
        !            34:        dutime = clock.tms_utime;
        !            35:        dstime = clock.tms_stime;
        !            36:        return(dt->usrtime + dt->systime);
        !            37: }

unix.superglobalmegacorp.com

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