skip to content

In the Angular DevTools Profiler tab, what does each bar of a recording represent, and how do you find the component that made one slow?

level: juniorimportance: should knowfreq 40%

answer

  1. one bar per something
  2. height means time
  3. select a bar to drill in
  4. bar chart or flame graph
  5. development builds only

basics

~20 s

Each bar is one change detection cycle, and its height is how long that cycle took; selecting a bar shows per-component and per-directive times as a bar chart or flame graph, so the widest entry is where to look first.

solid answer

~40 s

Angular DevTools is a browser extension; its **Profiler** tab records change detection and lifecycle hook execution while you interact with the app. The timeline shows one bar per change detection cycle, and a taller bar means Angular spent longer in that cycle. Selecting a bar shows the total time for the cycle, an estimated frame rate when it drops below 60 fps, and a bar chart of every component and directive it touched, sorted by time. Clicking one shows which methods (the template, `ngDoCheck`, other hooks) took the time and its parent hierarchy. A flame-graph view shows the same cycle along the element tree. The extension only works on development builds, and recordings can be saved as JSON and imported later.

go deeper

for a junior

Recall that each bar is one change detection cycle, taller means slower, and selecting it lists components by time spent.

for a middle

Explain the drill-down: cycle total, estimated frame rate, per-component bar chart, method breakdown and the flame graph's axes.

for a senior

Show you can use relative timings from a development build to pick the dominant component, and confirm the fix with a production-like trace.

for a principal

Decide when a saved Profiler recording is the right evidence for a performance bug, and when field data or production traces must back it up.

## What the Profiler records **Angular DevTools** is a browser extension for Chrome and Firefox that adds an "Angular" tab to the browser's developer tools. Its **Profiler** tab is dedicated to **change detection**, the pass in which Angular checks component views and updates the DOM. When you press record and interact with the app, the extension captures **execution events**: each change detection cycle, the components and directives processed in it, and the lifecycle hooks that ran. It does **not** record network, layout or paint. It answers one question: *where did Angular's own checking time go?* ## Reading the timeline After you stop recording, the Profiler shows a **sequence of bars**: - **Each bar is one change detection cycle.** Ten keystrokes that each trigger a cycle give you (at least) ten bars. - **Bar height is the time Angular spent in that cycle.** A tall bar in a row of short ones is the cycle to investigate. - **The number of bars matters too.** Many small bars for one interaction can mean something is triggering more cycles than expected. ## Drilling into one cycle Selecting a bar opens its detail view: 1. The **total time** Angular spent in that cycle. 2. An **estimated frame rate** as experienced by the user, shown when it falls below 60 fps. 3. A **bar chart** of every component and directive captured in that cycle, so the dominant one stands out. 4. Clicking an entry shows its **total time**, the **methods** that consumed it (for example the template function or `ngDoCheck`) and its **parent hierarchy**, which tells you where it sits in the app. ## The flame graph view A dropdown switches the same cycle to a **flame graph**: | Axis or cue | Meaning | |---|---| | x-axis | The full duration of the selected cycle | | y-axis | The element hierarchy: a component's children sit below it | | Tile colour intensity | Time spent there, relative to the most expensive tile in this cycle | | Click a tile | Details in the side panel | | Double-click a tile | Zoom into its subtree | The flame graph is the better view when the cost is spread across a subtree (a list of 300 row components) rather than concentrated in one component. A **Change detection** checkbox above the flame graph greys out components that were not actually checked in that cycle, for example `OnPush` components that were skipped, so you can see which parts of the tree Angular really visited. ## Saving and sharing **Save Profile** exports the recording as a JSON file; the Profiler's start screen can import one. This lets you attach a recording to a bug report, compare a before-and-after pair, or let a colleague inspect the same cycles. ## The development-build limitation The extension needs debug hooks that production optimizations strip out. On a production build it reports that it detected an application built with production configuration and supports only development builds. `ng serve` produces a suitable build by default; for a deployed environment you would build with optimization disabled. Two consequences: - Profiler numbers come from a **development build**, which does extra checking work, so treat the **absolute** times as inflated and focus on **relative** cost: which cycle, which component. - Confirm the improvement afterwards with the browser's own performance tools on a production-like build. ## Common misreadings - **Treating bars as frames.** A bar is a change detection cycle. Several cycles can fit in one frame, and one slow cycle can span several frames; the estimated frame rate is the Profiler's separate hint about user impact. - **Blaming the component you interacted with.** The component where the event happened is often cheap; the time usually sits in a sibling or a large child that the event caused Angular to check. - **Ignoring directives.** Structural and attribute directives appear in the bar chart too, and a directive running `ngDoCheck` on every cycle can dominate. - **Comparing across machines.** A recording from a fast laptop and one from a slow test device are not comparable; compare before and after on the same machine. ## Interview summary Say it in three steps: bars are cycles and height is time; pick the tall bar and read the component bar chart; open the dominant component to see whether its template or a hook spent the time. Then mention the flame graph for spread-out cost and the development-build caveat.

  • Angular DevTools says it detected an application built with production configuration. What does that mean and what can you do?
    Production optimizations strip the debug features the extension uses to talk to the app, so it cannot inspect or profile it. Profile locally with `ng serve`, or build the environment you need with optimization disabled. Treat the resulting timings as relative, because development builds do extra work.
  • When would you switch from the bar chart to the flame graph for a slow cycle?
    When no single component dominates the bar chart. The flame graph lays the cycle out along the element hierarchy, so a cost spread across many children, such as hundreds of row components under one list, shows up as a wide subtree even though each row is individually small.

The Profiler's timeline is like a till receipt per shopping trip: each bar is one trip, its height the total spent, and opening it itemises which components cost what.

saying these in an interview costs you the question

  • Each Profiler bar is one browser frame, not a change detection cycle
  • The Profiler shows network and layout time for each component
  • Angular DevTools can profile a production build as-is
  • Profiler timings match production timings exactly
  • Flame graph width is the number of child components