Reputation: 26476
I am looking for some advice on how to use Instruments' Time Profiler to enhance a specific operation. I have a paging scroll view that loads its content on demand. As a new page is scrolled to, another is loaded two pages to the right. This happens when the current page is scrolled 50% of screen, and on slower devices the loading is enough of a bottle neck that it interrupts the smoothness of the scroll. The scroll feels like it pauses very briefly at the 50% pint and then jumps back into action.
I should note that there is no network component to my application, so the bottle neck is not while data is fetched - it is all in the loading of the new view.
As I work on improving this, I need to benchmark the transition so I can evaluate the effect of my enhancements. Having watched the WWDC sessions, I understand the basics of the time profiler but I'm not confident I am looking at the right thing.
I am running the instrument and then executing the scroll. I see the expected spike in CPU activity. I am then selecting the spike and looking at the symbol names. As you can see below, when I hide system libraries and show Obj-C I am dealing a brief 90% spike with 81.0 ms of running time.
My confusion comes when I drill down to my code. I find that one of the largest contributors (23 ms) is a small routine that just uses sortedArrayUsingDescriptors
. Not much I can do about that one. Other times the root cause will me using CGRectInset - a few more milliseconds. I guess I expected to see more related to image use or something like that.
I guess I don't know if I'm benchmarking the right things. Am I really meant to try and reduce my 6ms operations down to 5ms and expect to see a difference? Am I looking at the right tools to diagnose my problem?
Any tips or instructions on what to measure and where to focus my efforts would be really valued.
Upvotes: 5
Views: 308
Reputation: 631
Consider using grand central dispatch to do as much non-UI work (fetching, sorting, selecting etc) as much as possible on a background thread. This will leverage the power of multi-cpu machines and get you off the main thread faster. Only using main thread for ui work as needed.
Upvotes: 1