Lesson 2 · Unit 01
Reading a profile
Self time, total time, call counts and flame graphs
What you practise
- Self time against total time, call counts, sampling against instrumenting, a flame graph read as text
Try a question from this lesson
Pick one
A profile of one run. Indentation shows who calls whom. Which function should you try to speed up first?
function calls self total
main 1 2ms 100ms
load 1 18ms 30ms
parse 500 12ms 12ms
render 1 5ms 68ms
layout 200 63ms 63msHint
Which column counts only the time spent in a function's own lines?
Correct answer
layout: its self time is 63 ms
Why
Total time includes everything a function calls, so main is always 100%. Self time is what a function burns in its own lines. layout spends 63 of the 100 ms itself; render mostly passes the time along.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Self and total
A profiler reports two times for every function.
Total time: from the moment it is called until it returns, including every function it calls.
Self time: only the time spent in its own lines.
So total = self + the totals of the functions it calls. Totals tell you which branch of the program is expensive. Self times tell you which function is doing the expensive work.
11 more exercises in the app
- 4× type the answer
- 4× multiple choice
- 1× match the pairs
- 1× true or false
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.