Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Instruments: profiled hotspots don't match up with source code

When using the Instruments time profiler, I often end up with results that don't make sense. They indicate that time is spent in some part of the file that is either outside of the function being inspected, or contains no executable code (comments, blank lines, etc.). This makes the results often close to useless.

I have tried a number of things to try to solve this:

  • Close Instruments before recompiling and re-profiling
  • Clean build, recompile
  • Restart instruments every time I profile
  • Updated to Xcode 4.3.2

These occasionally help, but don't always prevent the problem.

What can I do to fix this?

example of issue

like image 749
leecbaker Avatar asked Jun 05 '26 10:06

leecbaker


1 Answers

I was running into the same problem on code that I compiled using gcc with the -O3 optimization flag set. Googling around, I learned that Apple's time profiler does not like gcc code that is compiled with optimization flags.

Recompiling my code without the -O3 flag and rerunning the time profiler, hotspots now match the correct lines of my source code. Perhaps this relates to your problem.

like image 74
user1774582 Avatar answered Jun 07 '26 23:06

user1774582