Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-13-2011, 03:33 PM   #1
LQ Newbie
Registered: Aug 2011
Posts: 3

Rep: Reputation: Disabled
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.
Old 08-13-2011, 05:29 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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

Old 08-13-2011, 05:41 PM   #3
Senior Member
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,254

Rep: Reputation: 314Reputation: 314Reputation: 314Reputation: 314
The accurate of nanosleep() depends on kernel version, kernel configuration options (CONFIG_HZ, CONFIG_NO_HZ, CONFIG_HIGH_RES_TIMERS) and hardware clocks precision.
Old 08-13-2011, 10:09 PM   #4
LQ Veteran
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,807

Rep: Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168Reputation: 2168
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.

Last edited by syg00; 08-14-2011 at 01:26 AM. Reason: typo
Old 08-14-2011, 02:55 AM   #5
LQ Newbie
Registered: Aug 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
strace palisetty_suman Linux - Newbie 2 07-01-2012 08:24 AM
strace option mohit_parihar Linux - General 4 01-26-2010 11:39 PM
strace app RajRed Linux - Software 1 12-03-2005 12:39 AM
Usage of strace mdb84 Linux - Software 1 03-25-2005 02:13 AM
strace useradd phoenix_fei Programming 1 11-29-2004 10:32 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration