text
stringlengths
1
474
If you are running a Flutter application,
use a profile build to analyze performance.
CPU profiles are not indicative of release performance
unless your Flutter application is run in profile mode.<topic_end>
<topic_start>
CPU profiler
Start recording a CPU profile by clicking Record.
When you are done recording, click Stop. At this point,
CPU profiling data is pulled from the VM and displayed
in the profiler views (Call tree, Bottom up, Method table,
and Flame chart).To load all available CPU samples without manually
recording and stopping, you can click Load all CPU samples,
which pulls all CPU samples that the VM has recorded and
stored in its ring buffer, and then displays those
CPU samples in the profiler views.<topic_end>
<topic_start>
Bottom up
This table provides a bottom-up representation
of a CPU profile. This means that each top-level method,
or root, in the bottom up table is actually the
top method in the call stack for one or more CPU samples.
In other words, each top-level method in a bottom up
table is a leaf node from the top down table
(the call tree).
In this table, a method can be expanded to show its callers.This view is useful for identifying expensive methods
in a CPU profile. When a root node in this table
has a high self time, that means that many CPU samples
in this profile ended with that method on top of the call stack.
See the Guidelines section below to learn how to
enable the blue and green vertical lines seen in this image.Tooltips can help you understand the values in each column:Table element (self time)
<topic_end>
<topic_start>
Call tree
This table provides a top-down representation of a CPU profile.
This means that each top-level method in the call tree is a root
of one or more CPU samples. In this table,
a method can be expanded to show its callees.This view is useful for identifying expensive paths in a CPU profile.
When a root node in this table has a high total time,
that means that many CPU samples in this profile started
with that method on the bottom of the call stack.
See the Guidelines section below to learn how to
enable the blue and green vertical lines seen in this image.Tooltips can help you understand the values in each column:<topic_end>
<topic_start>
Method table
The method table provides CPU statistics for each method
contained in a CPU profile. In the table on the left,
all available methods are listed with their total and
self time.Total time is the combined time that a method spent
anywhere on the call stack, or in other words,
the time a method spent executing its own code and
any code for methods that it called.Self time is the combined time that a method spent
on top of the call stack, or in other words,
the time a method spent executing only its own code.Selecting a method from the table on the left shows
the call graph for that method. The call graph shows
a method’s callers and callees and their respective
caller / callee percentages.<topic_end>
<topic_start>
Flame chart
The flame chart view is a graphical representation of
the Call tree. This is a top-down view
of a CPU profile, so in this chart,
the top-most method calls the one below it.
The width of each flame chart element represents the
amount of time that a method spent on the call stack.Like the Call tree, this view is useful for identifying
expensive paths in a CPU profile.The help menu, which can be opened by clicking the ? icon
next to the search bar, provides information about how to
navigate and zoom within the chart and a color-coded legend.
<topic_end>
<topic_start>
CPU sampling rate
DevTools sets a default rate at which the VM collects CPU samples:
1 sample / 250 μs (microseconds). This is selected by default on
the CPU profiler page as “Cpu sampling rate: medium”.
This rate can be modified using the selector at the top
of the page.The low, medium, and high sampling rates are
1,000 Hz, 4,000 Hz, and 20,000 Hz, respectively.
It’s important to know the trade-offs
of modifying this setting.A profile that was recorded with a higher sampling rate
yields a more fine-grained CPU profile with more samples.
This might affect performance of your app since the VM
is being interrupted more often to collect samples.
This also causes the VM’s CPU sample buffer to overflow more quickly.
The VM has limited space where it can store CPU sample information.
At a higher sampling rate, the space fills up and begins
to overflow sooner than it would have if a lower sampling
rate was used.
This means that you might not have access to CPU samples
from the beginning of the recorded profile, depending
on whether the buffer overflows during the time of recording.A profile that was recorded with a lower sampling rate
yields a more coarse-grained CPU profile with fewer samples.
This affects your app’s performance less,
but you might have access to less information about what
the CPU was doing during the time of the profile.
The VM’s sample buffer also fills more slowly, so you can see
CPU samples for a longer period of app run time.
This means that you have a better chance of viewing CPU
samples from the beginning of the recorded profile.<topic_end>
<topic_start>
Filtering
When viewing a CPU profile, you can filter the data by