| |
|
| ntime ( -- dtime ) gforth |
ntime ( -- dtime ) gforth |
| ""Report the current time in nanoseconds since some epoch."" |
""Report the current time in nanoseconds since some epoch."" |
| #ifdef HAVE_CLOCK_GETTIME |
|
| struct timespec time1; |
struct timespec time1; |
| |
#ifdef HAVE_CLOCK_GETTIME |
| clock_gettime(CLOCK_REALTIME,&time1); |
clock_gettime(CLOCK_REALTIME,&time1); |
| dtime = timespec2ns(&time1); |
|
| #else |
#else |
| struct timeval time1; |
struct timeval time2; |
| gettimeofday(&time1,NULL); |
gettimeofday(&time2,NULL); |
| dtime = timeval2us(&time1) * 1000LL; |
time1.tv_sec = time2.tv_sec; |
| |
time1.tv_nsec = time2.tv_usec*1000; |
| #endif |
#endif |
| |
dtime = timespec2ns(&time1); |
| |
|
| \+ |
\+ |
| |
|