6
* Copyright (c) 1995 by PDCL Corporation. All Rights Reserved.
11
* Timing routines for calculating the execution time:
12
* void start_timer(void); Set the timer.
13
* double elapsed_time(void); Return the timing elapsed since
14
* the timer has been set.
16
* Jialin Ju - Oct 16, 1995 Created.
20
# include <sys/types.h>
23
# include <sys/errno.h>
26
# include <sys/time.h>
29
/** Timing routines that use standard Unix gettingofday() */
30
static struct timezone tz;
31
static struct timeval start_time, finish_time;
33
/** Start measuring a time delay */
34
void start_timer(void)
36
gettimeofday( &start_time, &tz);
39
/** Retunrn elapsed time in milliseconds */
40
double elapsed_time(void)
42
gettimeofday( &finish_time, &tz);
43
return(1000.0*(finish_time.tv_sec - start_time.tv_sec) +
44
(finish_time.tv_usec - start_time.tv_usec)/1000.0 );
47
/** Return the stopping time in milliseconds */
48
double stop_time(void)
50
gettimeofday( &finish_time, &tz);
51
return(1000.0*finish_time.tv_sec + finish_time.tv_usec/1000.0);