Hi, I'm using the following code to print the duration of a program. I'm using clock(), or if available clock_gettime() with CLOCK_PROCESS_CPUTIME_ID.
I'm just wondering if there's a way of getting the precision of clock_gettime with CLOCK_PROCESS_CPUTIME_ID when the system doesn't define CLOCK_PROCESS_CPUTIME_IDCode:#ifdef _POSIX_CPUTIME #ifdef CLOCK_PROCESS_CPUTIME_ID #define TELLTIME if( clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &duration1) == 0 ) {\ fprintf(stdout, "Time Elapsed: %lf seconds \n",(double)duration1.tv_nsec/NANOSECS);\ } else {\ perror("Error: clock_gettime() function error: ");\ } #else #define TELLTIME fprintf(stdout, "Time Elapsed: %.2f seconds.\n", (double)((double)clock()/CLOCKS_PER_SEC)); #endif #else #define TELLTIME ; #endif ... ... TELLTIME;
If anyone has any insight it would be appreciated.



LinkBack URL
About LinkBacks


