Performance Tools – React (2024)

Note:

As of React 16, react-addons-perf is not supported. Please use your browser’s profiling tools to get insight into which components re-render.

Importing

import Perf from 'react-addons-perf'; // ES6var Perf = require('react-addons-perf'); // ES5 with npm

Overview

React is usually quite fast out of the box. However, in situations where you need to squeeze every ounce of performance out of your app, it provides a shouldComponentUpdate() method where you can add optimization hints to React’s diff algorithm.

In addition to giving you an overview of your app’s overall performance, Perf is a profiling tool that tells you exactly where you need to put these methods.

See these articles for an introduction to React performance tooling:

Development vs. Production Builds

If you’re benchmarking or seeing performance problems in your React apps, make sure you’re testing with the minified production build. The development build includes extra warnings that are helpful when building your apps, but it is slower due to the extra bookkeeping it does.

However, the perf tools described on this page only work when using the development build of React. Therefore, the profiler only serves to indicate the relatively expensive parts of your app.

Using Perf

The Perf object can be used with React in development mode only. You should not include this bundle when building your app for production.

Getting Measurements

  • start()
  • stop()
  • getLastMeasurements()

Printing Results

The following methods use the measurements returned by Perf.getLastMeasurements() to pretty-print the result.

  • printInclusive()
  • printExclusive()
  • printWasted()
  • printOperations()
  • printDOM()

Reference

start()

stop()

Perf.start()// ...Perf.stop()

Start/stop the measurement. The React operations in-between are recorded for analyses below. Operations that took an insignificant amount of time are ignored.

After stopping, you will need Perf.getLastMeasurements() to get the measurements.

getLastMeasurements()

Perf.getLastMeasurements()

Get the opaque data structure describing measurements from the last start-stop session. You can save it and pass it to the other print methods in Perf to analyze past measurements.

Note

Don’t rely on the exact format of the return value because it may change in minor releases. We will update the documentation if the return value format becomes a supported part of the public API.

printInclusive()

Perf.printInclusive(measurements)

Prints the overall time taken. When no arguments are passed, printInclusive defaults to all the measurements from the last recording. This prints a nicely formatted table in the console, like so:

Performance Tools – React (1)

printExclusive()

Perf.printExclusive(measurements)

“Exclusive” times don’t include the times taken to mount the components: processing props, calling componentWillMount and componentDidMount, etc.

Performance Tools – React (2)

printWasted()

Perf.printWasted(measurements)

The most useful part of the profiler.

“Wasted” time is spent on components that didn’t actually render anything, e.g. the render stayed the same, so the DOM wasn’t touched.

Performance Tools – React (3)

printOperations()

Perf.printOperations(measurements)

Prints the underlying DOM manipulations, e.g. “set innerHTML” and “remove”.

Performance Tools – React (4)

printDOM()

Perf.printDOM(measurements)

This method has been renamed to printOperations(). Currently printDOM() still exists as an alias but it prints a deprecation warning and will eventually be removed.

Performance Tools – React (2024)
Top Articles
Bonds - Wirtschaft leicht erklärt | Handelszeitung
| New Hobby Box
Sdn Md 2023-2024
Exclusive: Baby Alien Fan Bus Leaked - Get the Inside Scoop! - Nick Lachey
jazmen00 x & jazmen00 mega| Discover
Patreon, reimagined — a better future for creators and fans
Loves Employee Pay Stub
Tv Guide Bay Area No Cable
Wausau Marketplace
Autobell Car Wash Hickory Reviews
Amateur Lesbian Spanking
Geometry Escape Challenge A Answer Key
Pollen Count Central Islip
13 The Musical Common Sense Media
Transformers Movie Wiki
The Connecticut Daily Lottery Hub
Jack Daniels Pop Tarts
Local Dog Boarding Kennels Near Me
Most McDonald's by Country 2024
Craigslist Blackshear Ga
Troy Bilt Mower Carburetor Diagram
Ratchet & Clank Future: Tools of Destruction
Rochester Ny Missed Connections
Wnem Tv5 Obituaries
480-467-2273
Tokyo Spa Memphis Reviews
55Th And Kedzie Elite Staffing
Motorcycle Blue Book Value Honda
Danielle Moodie-Mills Net Worth
Pronóstico del tiempo de 10 días para San Josecito, Provincia de San José, Costa Rica - The Weather Channel | weather.com
Jackass Golf Cart Gif
Infinite Campus Asd20
Login.castlebranch.com
Ezstub Cross Country
Rock Salt Font Free by Sideshow » Font Squirrel
RFK Jr., in Glendale, says he's under investigation for 'collecting a whale specimen'
Maybe Meant To Be Chapter 43
Dr. John Mathews Jr., MD – Fairfax, VA | Internal Medicine on Doximity
Myfxbook Historical Data
SF bay area cars & trucks "chevrolet 50" - craigslist
Blackwolf Run Pro Shop
Fifty Shades Of Gray 123Movies
Anhedönia Last Name Origin
If You're Getting Your Nails Done, You Absolutely Need to Tip—Here's How Much
'The Night Agent' Star Luciane Buchanan's Dating Life Is a Mystery
Cabarrus County School Calendar 2024
St Als Elm Clinic
Evil Dead Rise - Everything You Need To Know
Makemkv Key April 2023
Osrs Vorkath Combat Achievements
Gameplay Clarkston
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 5545

Rating: 4.4 / 5 (65 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.