1998-02-01 02:37:08 +01:00
|
|
|
#include "time.h"
|
1999-03-17 09:21:44 +01:00
|
|
|
|
|
|
|
#ifdef MSDOS
|
1999-05-03 10:35:22 +02:00
|
|
|
#undef USE_CLOCK
|
1999-03-17 09:21:44 +01:00
|
|
|
#define USE_CLOCK
|
|
|
|
#endif
|
|
|
|
|
1998-02-01 02:37:08 +01:00
|
|
|
#ifndef USE_CLOCK
|
1998-05-19 12:52:03 +02:00
|
|
|
#define _INCLUDE_POSIX_SOURCE /* for HP-UX */
|
|
|
|
#define _INCLUDE_XOPEN_SOURCE /* for HP-UX */
|
1998-02-01 02:37:08 +01:00
|
|
|
#include "sys/types.h"
|
|
|
|
#include "sys/times.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef Hz
|
|
|
|
#ifdef CLK_TCK
|
|
|
|
#define Hz CLK_TCK
|
|
|
|
#else
|
|
|
|
#ifdef HZ
|
|
|
|
#define Hz HZ
|
|
|
|
#else
|
|
|
|
#define Hz 60
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
double
|
|
|
|
dtime_ (float *tarray)
|
1998-02-01 02:37:08 +01:00
|
|
|
{
|
|
|
|
#ifdef USE_CLOCK
|
|
|
|
#ifndef CLOCKS_PER_SECOND
|
|
|
|
#define CLOCKS_PER_SECOND Hz
|
|
|
|
#endif
|
2002-06-01 14:38:32 +02:00
|
|
|
static double t0;
|
|
|
|
double t = clock ();
|
|
|
|
tarray[1] = 0;
|
|
|
|
tarray[0] = (t - t0) / CLOCKS_PER_SECOND;
|
|
|
|
t0 = t;
|
|
|
|
return tarray[0];
|
1998-02-01 02:37:08 +01:00
|
|
|
#else
|
2002-06-01 14:38:32 +02:00
|
|
|
struct tms t;
|
|
|
|
static struct tms t0;
|
1998-02-01 02:37:08 +01:00
|
|
|
|
2002-06-01 14:38:32 +02:00
|
|
|
times (&t);
|
|
|
|
tarray[0] = (double) (t.tms_utime - t0.tms_utime) / Hz;
|
|
|
|
tarray[1] = (double) (t.tms_stime - t0.tms_stime) / Hz;
|
|
|
|
t0 = t;
|
|
|
|
return tarray[0] + tarray[1];
|
1998-02-01 02:37:08 +01:00
|
|
|
#endif
|
2002-06-01 14:38:32 +02:00
|
|
|
}
|