NLSL
dtime.c
Go to the documentation of this file.
1 /*
2  * Returns the delta time since the last call to dtime.
3  *
4  * calling sequence:
5  * real time(2)
6  * call dtime(time)
7  * where:
8  * the 2 element array time will receive the user and system
9  * elapsed time since the last call to dtime, or since the start
10  * of execution.
11  *
12  * This routine can be called as function, and returns the sum of
13  * user and system times. The time_array argument must always be given.
14  *
15  * Original BSD-licensed routine replaced by WH 20020212 to fix
16  * bugs and non-portable code. This routine should conform to POSIX.
17  *
18  */
19 
20 #include <time.h>
21 #include <sys/times.h>
22 #include "fortrancall.h"
23 
24 float FORTRAN(dtime)(float *dt)
25 {
26  static time_t usr=0, sys=0;
27  struct tms theclock;
28 
29  times(&theclock);
30  dt[0] = (theclock.tms_utime - usr) / (float) CLK_TCK;
31  dt[1] = (theclock.tms_stime - sys) / (float) CLK_TCK;
32  usr = theclock.tms_utime;
33  sys = theclock.tms_stime;
34  return dt[0]+dt[1];
35 }
float FORTRAN() dtime(float *dt)
Definition: dtime.c:24
#define FORTRAN(n)
Definition: fortrancall.h:8