I have a problem recording a time interval (measured in at least milliseconds) on my MacOS (OS X EI Capitan 10.11.2).
Obviously, the main idea is to record time twice and do a subtraction. The problem arose when I found that gettimeofday () in "sys / time.h" and the struct for this function is struct timeval. Then I got the time interval and wanted to fall asleep according to the time interval. However, it seems that either nanosleep () or usleep () does not have an argument of type timeval (sleep () is ignored, since I need at least a millisecond).
Should I convert timeval to match nanosleep () or usleep (), or is there a better and easier way? Thanks in advance.
source
share