Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in...
Transcript of Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in...
![Page 1: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/1.jpg)
© 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Profile early, profile often
Developer Tools #WWDC16
Session 418
Using Time Profiler in Instruments
Kris Markel
![Page 2: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/2.jpg)
Agenda
Intro to profilingGoing fasterDoing lessImproving responsiveness
![Page 3: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/3.jpg)
A Better User Experience
![Page 4: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/4.jpg)
![Page 5: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/5.jpg)
![Page 6: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/6.jpg)
![Page 7: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/7.jpg)
How much and what kind of work is my app doing?
Profiling
![Page 8: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/8.jpg)
Time Profiler
![Page 9: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/9.jpg)
Measure, adjust, repeatInstruments
![Page 10: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/10.jpg)
Getting Started
![Page 11: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/11.jpg)
DemoProfiling an app
![Page 12: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/12.jpg)
main
method1 method2
method2 3 3
method1
method2 method2 3 method2
Time
![Page 13: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/13.jpg)
main
method1 method2
method2 3 3
method1
method2 method2 3 method2
Time
![Page 14: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/14.jpg)
main
method1 method2
method2 3 3
method1
method2 method2 3 method2
Time
![Page 15: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/15.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2 method2 3 method2
Time
![Page 16: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/16.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2 method2 3 method2
main()
method1()
method2()
1
1
1
Time
![Page 17: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/17.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2 method2 3 method2
main()
method1()
method2()
1
1
1
Time
![Page 18: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/18.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2 method2 3 method2
main()
method1()
method2()
1
1
1
Time
![Page 19: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/19.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 ms
main()
method1()
method2()
1
1
1
Time
![Page 20: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/20.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 msTime
main()
method1()
method2()
2
2
2
![Page 21: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/21.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 msTime
main()
method1()
method2()
2
2
2
![Page 22: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/22.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 msTime
main()
method1()
method2()
2
2
2
![Page 23: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/23.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
main()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 msTime
main()
method1()
method2()
2
2
2
![Page 24: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/24.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
main()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
1 msTime
main()
method1()
method2()
method2()
3
2
2
1
![Page 25: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/25.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
main()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
main()
method1()
method2()
main()
method1()
method2()
1 msTime
main()
method1()
method2()
method2()
3
2
2
1
![Page 26: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/26.jpg)
main
method1 method2
method2 3 3
main()
method1()
method2()
main()
method2()
method1
method2
main()
method1()
method2()
method2 3 method2
main()
method1()
method2()
main()
method1()
method2()
1 msTime
main()
method1()
method2()
method2()
5
4
4
1
![Page 27: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/27.jpg)
The Call Tree
main()
method1()
method2()
method2()
5
4
4
1
![Page 28: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/28.jpg)
The Call Tree
Doesn’t measure duration
main()
method1()
method2()
method2()
5
4
4
1
![Page 29: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/29.jpg)
The Call Tree
Doesn’t measure durationAggregates samples into a useful summary
main()
method1()
method2()
method2()
5
4
4
1
![Page 30: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/30.jpg)
The Call Tree
Doesn’t measure durationAggregates samples into a useful summary• Long running vs. repetitive main()
method1()
method2()
method2()
5
4
4
1
![Page 31: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/31.jpg)
The Call Tree
Doesn’t measure durationAggregates samples into a useful summary• Long running vs. repetitive main()
method1()
method2()
method2()
5
4
4
1
![Page 32: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/32.jpg)
The Call Tree
Doesn’t measure durationAggregates samples into a useful summary• Long running vs. repetitive
Focuses on CPU usage
main()
method1()
method2()
method2()
5
4
4
1
![Page 33: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/33.jpg)
The Call Tree
Doesn’t measure durationAggregates samples into a useful summary• Long running vs. repetitive
Focuses on CPU usage• Doesn’t capture everything
main()
method1()
method2()
method2()
5
4
4
1
![Page 34: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/34.jpg)
DemoGoing faster and doing less
![Page 35: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/35.jpg)
Starting the Investigation
Look for the unexpected• Trackpad friendly• Drag to apply a filter• Draggable filter edges• Option-drag to zoom in control-drag to zoom out• Data values on hover
![Page 36: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/36.jpg)
What We Did
![Page 37: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/37.jpg)
What We Did
Going faster
![Page 38: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/38.jpg)
What We Did
Going faster• Focused on an area of high CPU usage
![Page 39: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/39.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening
![Page 40: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/40.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening• Walked back to our code
![Page 41: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/41.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening• Walked back to our code• Inspected our code
![Page 42: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/42.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening• Walked back to our code• Inspected our code• Made it faster
![Page 43: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/43.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening• Walked back to our code• Inspected our code• Made it faster• Verified the changes
![Page 44: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/44.jpg)
What We Did
Going faster• Focused on an area of high CPU usage• Examined the call tree, looking for where the work was happening• Walked back to our code• Inspected our code• Made it faster• Verified the changes• Saved the user’s time
![Page 45: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/45.jpg)
What We Did
![Page 46: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/46.jpg)
What We Did
Doing less
![Page 47: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/47.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage
![Page 48: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/48.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage• Examined the call tree
![Page 49: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/49.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage• Examined the call tree• Determined the frameworks involved
![Page 50: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/50.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage• Examined the call tree• Determined the frameworks involved• Stopped doing unnecessary work
![Page 51: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/51.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage• Examined the call tree• Determined the frameworks involved• Stopped doing unnecessary work• Verified the changes
![Page 52: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/52.jpg)
What We Did
Doing less• Focused on low, but unexpected CPU usage• Examined the call tree• Determined the frameworks involved• Stopped doing unnecessary work• Verified the changes• Improved battery life
![Page 53: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/53.jpg)
Responsiveness
![Page 54: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/54.jpg)
Responsiveness
![Page 55: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/55.jpg)
Responsiveness
The main thread does all the UI work
![Page 56: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/56.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events
![Page 57: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/57.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance
![Page 58: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/58.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain
![Page 59: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/59.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 60: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/60.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 61: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/61.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 62: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/62.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 63: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/63.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 64: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/64.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 65: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/65.jpg)
Responsiveness
The main thread does all the UI work• Run loop waiting for events• Sends events to your UIApplication instance• Passes through the responder chain• Your code gets invoked
![Page 66: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/66.jpg)
Responsiveness
![Page 67: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/67.jpg)
Responsiveness
When busy, the main thread can’t process events
![Page 68: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/68.jpg)
Responsiveness
When busy, the main thread can’t process events• The queue backs up
![Page 69: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/69.jpg)
Responsiveness
When busy, the main thread can’t process events• The queue backs up• Stuttering and hiccups
![Page 70: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/70.jpg)
Responsiveness
When busy, the main thread can’t process events• The queue backs up• Stuttering and hiccups• App becomes unresponsive
![Page 71: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/71.jpg)
Responsiveness
When busy, the main thread can’t process events• The queue backs up• Stuttering and hiccups• App becomes unresponsive
Keep the main thread free
![Page 72: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/72.jpg)
DemoImproving responsiveness
![Page 73: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/73.jpg)
What We Did
![Page 74: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/74.jpg)
What We Did
Responsiveness
![Page 75: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/75.jpg)
What We Did
Responsiveness• Examined the CPU spikes
![Page 76: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/76.jpg)
What We Did
Responsiveness• Examined the CPU spikes• Focused on the main thread
![Page 77: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/77.jpg)
What We Did
Responsiveness• Examined the CPU spikes• Focused on the main thread• Identified non-UI work happening on the main thread
![Page 78: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/78.jpg)
What We Did
Responsiveness• Examined the CPU spikes• Focused on the main thread• Identified non-UI work happening on the main thread• Distributed the work across multiple threads
![Page 79: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/79.jpg)
What We Did
Responsiveness• Examined the CPU spikes• Focused on the main thread• Identified non-UI work happening on the main thread• Distributed the work across multiple threads• Verified the changes
![Page 80: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/80.jpg)
What We Did
Responsiveness• Examined the CPU spikes• Focused on the main thread• Identified non-UI work happening on the main thread• Distributed the work across multiple threads• Verified the changes• Achieved a better user experience
![Page 81: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/81.jpg)
Regarding Optimization
![Page 82: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/82.jpg)
Regarding Optimization
The fixes were simple, but added complexity
![Page 83: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/83.jpg)
Regarding Optimization
The fixes were simple, but added complexity By finding them early in the development process, there’s more time to verify correctness
![Page 84: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/84.jpg)
Regarding Optimization
The fixes were simple, but added complexity By finding them early in the development process, there’s more time to verify correctnessProfile early, profile often!
![Page 85: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/85.jpg)
Regarding Optimization
The fixes were simple, but added complexity By finding them early in the development process, there’s more time to verify correctnessProfile early, profile often!Sometimes get big gains for little effort
![Page 86: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/86.jpg)
Best Practices
Always profile release buildsAlways profile on the deviceRun with old devicesUse large data sets where it makes sense• Look for poorly scaling code (O(n2), etc.)
![Page 87: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/87.jpg)
Summary
![Page 88: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/88.jpg)
Summary
If you want …
![Page 89: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/89.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
![Page 90: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/90.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application
![Page 91: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/91.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application- Better battery life
![Page 92: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/92.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application- Better battery life- More responsive UI
![Page 93: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/93.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application- Better battery life- More responsive UI
Then you should …
![Page 94: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/94.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application- Better battery life- More responsive UI
Then you should …• Profile early
![Page 95: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/95.jpg)
Summary
If you want …• The best experience for your users across all the devices you support
- A faster application- Better battery life- More responsive UI
Then you should …• Profile early• Profile often
![Page 96: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/96.jpg)
More Information
https://developer.apple.com/wwdc16/418
![Page 97: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/97.jpg)
Related Sessions
Optimizing App Startup Time Mission Wednesday 10:00AM
System Trace in Depth Nob Hill Thursday 9:00AM
Thread Sanitizer and Static Analysis Mission Thursday 10:00AM
Optimizing I/O for Performance and Battery Life Nob Hill Friday 11:00AM
Concurrent Programming with GCD in Swift 3 Pacific Heights Friday 4:00PM
Unified Logging and Activity Tracing Nob Hill Friday 5:00PM
Profiling in Depth WWDC 2015
![Page 98: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/98.jpg)
Labs
Xcode Open Hours Developer Tools Lab B Friday 3:00PM
Swift Open Hours Developer Tools Lab A Friday 3:00PM
![Page 99: Developer Tools #WWDC16€¦ · Developer Tools #WWDC16 Session 418 Using Time Profiler in Instruments Kris Markel. Agenda Intro to profiling Going faster Doing less Improving responsiveness.](https://reader036.fdocuments.in/reader036/viewer/2022071014/5fcd607521fb6f38f37985b5/html5/thumbnails/99.jpg)