void handle_start() {
- if(clock_gettime(CLOCK_MONOTONIC, start_time) == -1) {
+ if(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, start_time) == -1) {
printf("failed to get start time.\n");
exit(1);
}
-
- pause();
}
void handle_stop() {
long int start_sec, stop_sec, delta;
- if(clock_gettime(CLOCK_MONOTONIC, stop_time) == -1) {
+ if(clock_gettime(CLOCK_PROCESS_CPUTIME_ID, stop_time) == -1) {
printf("failed to get stop time.\n");
exit(1);
}
- start_sec = ((long int) start_time->tv_sec);
- stop_sec = ((long int) stop_time->tv_sec);
+ start_sec = ((long int) start_time->tv_nsec);
+ stop_sec = ((long int) stop_time->tv_nsec);
delta = stop_sec - start_sec;
- printf("%ld seconds elapsed between signals.\n", delta);
+ printf("%ld nanoseconds elapsed between signals.\n", delta);
done = 1;
}
pause();
if(!done)
- goto terminate_check;
+ goto terminate_check; /* sorry */
free(start_time);
free(stop_time);