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: }

Defined functions

dtime_ defined in line 27; never used

Defined variables

dutime defined in line 25; used 2 times

Defined struct's

tb defined in line 23; used 2 times
  • in line 28(2)
Last modified: 1981-02-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 613
Valid CSS Valid XHTML 1.0 Strict