|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)dtime_.c 5.1 6/7/85 ! 7: */ ! 8: ! 9: /* ! 10: * Returns the delta time since the last call to dtime. ! 11: * ! 12: * calling sequence: ! 13: * real time(2) ! 14: * call dtime(time) ! 15: * where: ! 16: * the 2 element array time will receive the user and system ! 17: * elapsed time since the last call to dtime, or since the start ! 18: * of execution. ! 19: * ! 20: * This routine can be called as function, and returns the sum of ! 21: * user and system times. The time_array argument must always be given. ! 22: * ! 23: * The resolution for all timing is 1/60 second. ! 24: */ ! 25: ! 26: #include <sys/types.h> ! 27: #include <sys/times.h> ! 28: ! 29: struct tb { float usrtime; float systime; }; ! 30: ! 31: time_t dutime=0, dstime=0; ! 32: ! 33: float ! 34: dtime_(dt) struct tb *dt; ! 35: { struct tms clock; ! 36: ! 37: times(&clock); ! 38: dt->usrtime = (float)(clock.tms_utime - dutime) / 60.0; ! 39: dt->systime = (float)(clock.tms_stime - dstime) / 60.0; ! 40: dutime = clock.tms_utime; ! 41: dstime = clock.tms_stime; ! 42: return(dt->usrtime + dt->systime); ! 43: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.