How accurate is strace?
Greetings all,
Anyone know how accurate strace is when displaying the time taken to execute a system call? The reason I ask is if I use nanosleep(100000) in a program then compile it and do a "strace -T" is shows 0.100080 which is an error of 80uS (a lifetime on a 1.7GHz PC). In most situations such a small error is of no consequence but there are times when it does make a difference. Is the error in strace or in nanosleep? B.T.W. a printf("some_text") takes 50uS to execute on the same computer according to strace. Thanking you in advance. |
Just a hypothetical answer: executing a program under strace (or
anything other than a hardware debugger) would naturally incur a performance penalty? Cheers, Tink |
The accurate of nanosleep() depends on kernel version, kernel configuration options (CONFIG_HZ, CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS) and hardware clocks precision.
|
I use strace more for functionality rather than precision - I often just use relative timing. But for comparison, not absolute timings.
Maybe have a look at perf stats or (kernel) function tracing. |
Thank you all for your comments and guidance.
I did expect an overhead running strace I just didn't expect 80uS worth. I will investigate the kernel config. options and look at perf stats. Thanks once again. |
All times are GMT -5. The time now is 02:25 AM. |