I am trying to understand the precision of the gettimeofday() system call. Here’s my program: The output if I run this program (./a.out 10) is, The seconds column seems to reconcile with the sleep of 1 secs. Can someone please explain what’s going on with the values in micro seconds column? It looks like the jumps from sleep to sleep
Tag: gettimeofday
Why does a timerfd periodic Linux timer expire a little before than expected?
I am using a Linux periodic timer, in particular, timerfd, which I set to expire periodically, for instance, every 200 ms. I noticed, however, that the timer seems to expire, sometimes, a little before with respect to the timeout I set. In particular, I’m using the following C code to perform a simple test: After compiling it with gcc: I’m
Control loop time with usleep
I try to make sure the execution time of each loop to 10ms with usleep , but sometimes it exceeds 10ms. I have no idea how to solve this problem, is it proper to use usleep and gettimeofday in this case? Please help my find out what i missed. Result: 0.0127289 0.0136499 0.0151598 0.0114031 0.014801 Answer To keep the loop
Computation time of processor varies on execution, each time by using gettimeofday() in a C program
I am trying to compare the computation time for performance comparison using different C libraries with gettimeofday() by including time.h and sys/time.h header files. I used gettimeofday() at the start and end of my computation and took the difference. But each time I execute my C code, I get fluctuating time as answer. For example Is there a way I