Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're not alone in conflating the terms "profiling" and "optimizing", but they're really very different. As different as weighing a book versus reading it.</p> <p>As far as gprof goes, <a href="https://stackoverflow.com/questions/1777556/alternatives-to-gprof/1779343#1779343">here are some issues</a>.</p> <p>Among profilers, the most useful are the ones that</p> <ul> <li><p>Sample the whole call stack (not just the program counter) or at least as much of it as contains your code.</p></li> <li><p>Samples on wall-clock time (not just CPU time). If you're losing time in I/O or other blocking calls, a CPU-only profiler will simply not see it.</p></li> <li><p>Tells you by line-of-code (not just by function) the percent of stack samples containing that line. That's important because any such line of code that you could eliminate would save you that percent of overall time, and you don't have to eyeball functions to guess where it is.</p></li> </ul> <p>A good profiler for linux that does this is <a href="http://www.rotateright.com/" rel="nofollow noreferrer">Zoom</a>. I'm sure there are others. (Don't get confused about what matters. Efficiency and/or timing accuracy of a profiler is not important for helping you locate speed bugs. What's important is that it draws your attention to the right things.)</p> <p>Personally, I use the <a href="https://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024">random-pausing</a> method, because I find it's the most effective. Not only is it simple and requires no investment, but it finds speedup opportunities that are not localized to particular routines or lines of code, <a href="https://stackoverflow.com/questions/7916985/what-is-boilerplate-code-hot-code-and-hot-spots/7923574#7923574">as in this example</a>. This is reflected in the <a href="https://stackoverflow.com/questions/926266/performance-optimization-strategies-of-last-resort/927773#927773">speedup factors that can be achieved</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload