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
What is impermanent loss in cryptocurrency? | CoinLedger
Are Air Fryers Energy Efficient? | The Eco Experts
Is Sam's Club Plus worth it? What to know about the premium warehouse membership before you sign up
Chicago Neighborhoods: Lincoln Square & Ravenswood - Chicago Moms
Overnight Cleaner Jobs
Retro Ride Teardrop
Noaa Swell Forecast
Gameplay Clarkston
Whiskeytown Camera
Morgan Wallen Pnc Park Seating Chart
Large storage units
Hallelu-JaH - Psalm 119 - inleiding
Scenes from Paradise: Where to Visit Filming Locations Around the World - Paradise
Bitlife Tyrone's
Daily Voice Tarrytown
Craigslist Maui Garage Sale
How your diet could help combat climate change in 2019 | CNN
Azur Lane High Efficiency Combat Logistics Plan
Craigslist Apartments Baltimore
[PDF] PDF - Education Update - Free Download PDF
Craigslist Roseburg Oregon Free Stuff
SOGo Groupware - Rechenzentrum Universität Osnabrück
Bolly2Tolly Maari 2
Delta Math Login With Google
Alternatieven - Acteamo - WebCatalog
49S Results Coral
Franklin Villafuerte Osorio
Frequently Asked Questions - Hy-Vee PERKS
Fbsm Greenville Sc
Petsmart Northridge Photos
Scottsboro Daily Sentinel Obituaries
3400 Grams In Pounds
Henry County Illuminate
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
Dee Dee Blanchard Crime Scene Photos
Craigslist en Santa Cruz, California: Tu Guía Definitiva para Comprar, Vender e Intercambiar - First Republic Craigslist
Mississippi weather man flees studio during tornado - video
ESA Science & Technology - The remarkable Red Rectangle: A stairway to heaven? [heic0408]
Free Crossword Puzzles | BestCrosswords.com
Anthem Bcbs Otc Catalog 2022
Levi Ackerman Tattoo Ideas
Oklahoma City Farm & Garden Craigslist
The Machine 2023 Showtimes Near Roxy Lebanon
Craigslist Sarasota Free Stuff
Electric Toothbrush Feature Crossword
Skyward Login Wylie Isd
David Turner Evangelist Net Worth
Estes4Me Payroll
How to Get a Check Stub From Money Network
Coldestuknow
Vt Craiglist
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.