I have created a demo app that applies multiple filters to an image (it is inside the project) and shows buttons in a UIScrollView
with that images set as a background image. So, all the logic happens in a method that is called right from viewDidLoad
. I'm not using any threading mechanism, so all the work is happening on the main thread.
I'm using Instruments
, specifically Time Profiler
to find out why the app launches so slow (it is obvious, but I would like to see it in Time Profiler
).
When I run it I get the following result in the detail panel (in the root):
And when I press the arrow to see the actual code I get the following:
And this is for every filter operation.
Shouldn't the panel show the actual method inside of which I do filtering?
The main
function is not the cause of your app being slow. In your screenshot the listing for main
says you spent 0 seconds in main
.
The Time Profiler instrument records the call stack 1000 times per second. The main
function is the starting point for your app. That means main
is going to be on the call stack most of the time your app is running, even though your app is not in main
most of that time. The main
function being on the call stack is the reason for the 649 ms and 95.5% listings in your screenshot.
Do not worry about the listing for the main
function. You have no control over main
.
If you want to find your functions in the call tree, select the Invert Call Tree and Hide System Libraries checkboxes. Selecting those checkboxes makes it easier to find your code in the call tree.