Profiling in the Browser

Learn about how to find and analyze key metrics in the browser tools.


Profiling Web Applications in the Browser

In Optimization Recommendations and Requirements, we stressed the importance of profiling web applications before beginning any optimization. Here, we give an overview of how browser developer tools can be used to profile application metrics

In this section, we use screenshots from Chrome, as it is has the largest user base. However, developer tooling functions similarly across browsers. For instance, Edge and Chrome use the exact same developer tools, with some minor UI differences. Safari has a slightly different collection of tools, but it can be used to achieve similar results. In the next section, we provide platform-specific resources for profiling web applications.

🧰 Accessing Developer Tools

Developer Tools in Chrome

Most profiling utilities are accessible in the "Developer Tools" menu (Web Inspector in Safari). This menu is accessed in a different way on each browser:

Browser
Command

Chrome

Ctrl-Shift-J (Windows) Command-Option-K (Mac)

Edge

F12

Safari

Command-Option-C

Firefox

Ctrl-Shift-K. (Windows) Command-Option-K (Mac)

⏱️ Profiling Application Metrics

The Developer Tools browser menu can be used to access profilers for the core application metrics described in Optimization Recommendations and Requirements. Here, we give an overview of generating profiles with these tools and interpreting the results.

Overview

We recommend enabling the built-in FPS overlay on desktop devices while developing an application. This allows developers to quickly detect if a change has impacted performance, even when not they are not doing optimization work. This helps prevent performance regressions from accidentally getting out to users.

Guide: Enabling the FPS Overlay

Focus the Developer Tools Menu and enter ctrl/cmd + shift + P . This opens a search menu:

Type "show FPS" into the search menu and hit Enter

Observe the FPS counter in the top left corner of the application.

Interpreting Results

  • Average FPS is displayed at the top of the overlay (69.6 FPS in the picture above)

  • Variance in FPS can be determined from the colored bar below the average FPS. Yellow segments represent samples above 60 fps, while red segments represent samples below 60 fps. In the image above, FPS is hovering around 60 fps, so short red segments are interspersed with short yellow segments.

  • In a well-optimized application, all segments will be yellow:

  • In a poorly-optimized application, many segments will be red:

  • GPU memory usage is displayed at the bottom of the overlay. GPU performance typically scales with memory usage. In the image above, there is very little GPU overhead.

📱 Profiling Mobile Devices

There are two main ways to capture mobile performance metrics:

  • directly profiling a connected mobile device

  • emulating a mobile device in the browser

These techniques should be used in combination. Profiling mobile hardware gives more representative data, while emulation can be used to provide a wider range of data points. Crucially, GPU performance does not scale in browser emulators, so frame rate may be higher in the emulator. Emulators should primarily be used to approximate CPU performance across a range of devices and to validate image quality across a range of resolutions.

Prerequisites

  1. Access to an Android Device

  2. Install Android Debug Bridge (ADB) to connect to the android device.

  3. Install Chrome or Edge on your desktop/laptop computer. In Edge, replace chrome:// with edge:// for the following steps.

Connecting to an Android Device via USB

  1. Connect an android device via USB

  2. In a terminal, run adb devices to start the debugging server

  3. Navigate to chrome://inspect/devices and click "inspect" the connected device

  4. This brings up the Developer Tools menu for the connected device. From here, profiling is the same as on a desktop

Generating Native Performance Profiles

  1. In chrome://inspect/devices, select the "trace" option.

  2. If debugging an Android XR device, select Edit categories > check xr.debug

  3. Click record to begin generating a native trace.


Profiling Resources for Web Browsers and Devices

Beyond the overview we have provided, each browser provides detailed guides for debugging and profiling applications. Here we provide lists of resources for each major browser, as well as resources for connecting to mobile devices from Chrome and Safari.

Platform Support

🖥️ Desktop & 📱 Mobile

Core Developer Tools

Additional Tooling

Mobile Tooling

Last updated

Was this helpful?