0

Possible Duplicate:
What's your favorite profiling tool (for C++)

Instead of do it directly inside the C code, I want a some tool to do it for me. e.g, given some C code, it returns how long time it's was executed. Something like LinqPad and most client that given a SQL-query,it returns how time the query was executed in *conds.

Community
  • 1
  • 1
Jack
  • 16,276
  • 55
  • 159
  • 284
  • 1
    Do you need to know how long it took in "actual" time, or how much time was spent executing each function relative to the code as a whole? There are tools which do the latter which are likely ideal. They tell you where your optimization effort will yield the best result overall. – Brian Cain Sep 23 '12 at 02:41
  • Are you using Windows or Linux or some other os and what is the compiler? – Tanmoy Bandyopadhyay Sep 23 '12 at 02:51
  • Another duplicate: [Performance profiling on Linux](http://stackoverflow.com/q/1875167/62576), found with a search for `[c] profiling` here on SO. – Ken White Sep 23 '12 at 03:02

1 Answers1

1

You many try

1)GNU profiler (gprof) for function level profiling

http://www.cs.utah.edu/dept/old/texinfo/as/gprof.html#SEC2

2)For overall time statistics you may use the command,

time 

Example

3)You can also try parsing the files in /proc (/proc/[pid]/stat) for a particular process,

proc manual