LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How accurate is strace? (https://www.linuxquestions.org/questions/linux-newbie-8/how-accurate-is-strace-897152/)

cat_n_mouse 08-13-2011 03:33 PM

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.

Tinkster 08-13-2011 05:29 PM

Just a hypothetical answer: executing a program under strace (or
anything other than a hardware debugger) would naturally incur
a performance penalty?


Cheers,
Tink

eSelix 08-13-2011 05:41 PM

The accurate of nanosleep() depends on kernel version, kernel configuration options (CONFIG_HZ, CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS) and hardware clocks precision.

syg00 08-13-2011 10:09 PM

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.

cat_n_mouse 08-14-2011 02:55 AM

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.