Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Identifying Costly Components with Profiler Evidence

In our previous lesson, you successfully captured a performance profile of our sample application's list-filtering interaction. By recording the browser's activity while typing "hat", you learned to navigate the React Profiler's commit timeline and pinpoint the most expensive commit—the one that took the longest to render.

This lesson takes you one level deeper. Now that you've isolated the most time-consuming update, your goal is to analyze the data within that commit. We'll explore the Profiler's main visualization tools, the Flame Chart and the Ranked Chart, to use the evidence you've gathered to identify the single component that contributes most to the render cost.

Deconstructing a Commit: The Flame Chart

When you select a commit in the Profiler timeline, the main panel displays a flame chart. This chart is a visual representation of all the components that rendered during that specific commit. Think of it as a snapshot of your component tree at the moment of the update.

Each bar in the chart is a component.

  • The width of a bar represents the total time it took to render that component and all of its children. Wider bars mean more time spent.
  • The color also indicates render time, with yellow bars being more expensive than blue or gray ones. Gray bars indicate components that did not re-render in this particular commit.

Take a look at the recording you made in the last lesson. Select the most expensive commit (the tallest, yellowest bar) and examine the flame chart. You'll see a hierarchy of components. The components at the top of the chart are parents, and the components nested underneath are their children.

A crucial concept when reading this chart is the difference between total time and self time.

  • Total time (or inclusive time) is the duration shown by the width of the bar. It's the time spent rendering the component itself plus the time spent rendering its entire subtree. A component like App might have a very large total time because it's the root.
  • Self time is the time spent only in the component's own render logic, excluding its children. When you select a component, the Profiler's right-hand details panel shows you both numbers.

This distinction is vital. A component might be "expensive" because its own code is slow (high self time), or because it renders a huge, complex tree of children (high total time, low self time).

The following video explains how to interpret the flame chart, including this important distinction between the time spent in a component versus its children.

How To Maximize Performance In Your React Apps

Watch this segment from the "How To Maximize Performance In Your React Apps" video by Web Dev Simplified.

Pay close attention to the explanation starting around the flame chart. The presenter does an excellent job of breaking down the difference between the total render time of a component and its self-time. This will help you understand whether a component is slow on its own, or just has a lot of children.

The Fastest Way to Find the Worst Offender: The Ranked Chart

While the flame chart gives you a great structural overview, navigating a wide and deep tree to find the most expensive component can be tedious. The Profiler offers a more direct tool for this purpose: the Ranked Chart.

As its name implies, the Ranked Chart takes all the components that rendered in a commit and displays them as a simple list, sorted by how long they took to render. The component that took the most time is at the top.

Profiling React component performance with Chrome devtools

This article from the Calibre blog provides a concise guide to using the Profiler. We'll focus on its description of the two chart types.

Read the section Read the flame chart and ranked chart. It perfectly summarizes the purpose of the ranked chart as "the fastest way to spot the worst offender in a busy commit."

Now, let's see this in action. The video below demonstrates switching to the ranked chart view to immediately pinpoint a performance bottleneck.

How To Maximize Performance In Your React Apps

Let's return to the "How To Maximize Performance" video.

In this short clip, from the ranked chart, you'll see how switching views instantly reveals the component contributing the most to the slow render.

Your Turn: Identify the Culprit

With this knowledge, it's time to analyze the profile you recorded.

  1. In the React DevTools Profiler, make sure you have the most expensive commit from your "hat" filtering interaction selected.
  2. Switch from the "Flamegraph" view to the "Ranked" view using the tabs at the top of the panel.
  3. Examine the list. What is the name of the component at the very top?

This component is the primary target for our optimization efforts. It's the one that, for this specific interaction, consumed the most time during the render phase. In the right-hand panel, you can see its render duration, along with the props and state it had at the time of the commit.

For our sample project, you will likely see a component related to the list itself or the page containing it at the top of the ranked chart. This confirms our initial suspicion that the list filtering operation is causing significant rendering work.

Conclusion

In this lesson, you drilled down into a specific commit to find the root cause of its expense. You've learned how to use the Profiler's data visualizations to move from a general sense of "slowness" to a specific, actionable piece of evidence.

Here are the key takeaways:

  • The Flame Chart provides a hierarchical view of a commit, showing the entire rendered component tree. Its bar widths represent the total render time (self + children).
  • The Ranked Chart provides a sorted list of rendered components, ordered from most to least expensive. It's the most direct way to identify the component that took the longest to render.
  • By using the Ranked Chart, you can confidently identify the primary "culprit" contributing to a slow update.

You have now completed the first major phase of performance analysis: you've established a baseline, recorded a profile, and used profiler evidence to identify the most expensive component.

In the next lesson, we'll begin our work on fixing the problem. We'll investigate why that top component is re-rendering, tracing the update back to a specific change in its props, state, or context.

Can't find a good explanation? Sign up and we'll make it for you

Sign up