I'm just curious really, there doesn't seem to be any counter arguments. So should a profiler be used for everything? I'd imagine the performance gain would require make it beneficial every time.
4 Answers
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"
Profile when needed, otherwise you will waste hours of your precious time on saving milliseconds of machine cheap time.

- 23,300
- 18
- 98
- 136
Profilers tend to slow your code down significantly, so they should definitely not be used in production code. I also wouldn't use one for development unless I was specifically looking for performance problems, since it increases the time taken in the code / test cycle.

- 53,280
- 21
- 146
- 188
-
1+1 - Think of it like debugging; all the extra hooks that have to be executed through the code slows it down significantly. – Jesse Webb Feb 13 '12 at 23:13
If you have a very performance-critical application, then profile as much as possible during your development cycle so you can find your potential bottlenecks as early as possible and adjust your designs around them.
Otherwise, only profile when you run into an unexpected performance problem, have questions about the performance of specific algorithms or subsystems, or near the end of the development cycle if you have time leftover to work on improving performance even if it's not strictly necessary.
In most cases getting the application to work as expected on time is much more important than getting it to run fast, and profiling can eat up a lot of development time.

- 23,011
- 10
- 73
- 102
Profile periodically, as needed.
Don't worry about the performance of a profiler.
Its job is to identify your performance problem, not to pretend you don't have one.
Actually...
I don't use profilers. I do this instead, because it works better.
Profilers only tell you about certain kinds of problems - those that can be localized to a function.
After you fix the problems they tell you about, you are left being limited by the ones they don't tell you about. There's a PDF slide show here, showing how this works.

- 1
- 1

- 40,059
- 14
- 91
- 135