Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

How to try the new React Profiler

Before the holiday break, I was experimenting with a new profiler UI that may eventually make its way into a released version of the React DevTools. In the meanwhile, for anyone who is curious, here's how you can try this new profiler for yourself!

Building React

To start, you'll need an updated version of React that logs the new performance marks used by this profiler.

To do this, you'll need to check out PR 17772 and build it from source: yarn install && yarn build --type=NODE. (In the future I may publish an experimental release to NPM to simplify this step.)

Running the Profiler

Next you'll want to run the actual Profiler (currently built on top of Mozilla's perf.html profiler). I've been pushing my changes to a branch here which you can build (yarn install && yarn start). Or if you'd like, just use the preview build I deployed publically to dist-nine-murex.now.sh.

Gathering a Profile

Next you'll want to run the special build of React to collect a profile. This is the most labor intensive step.

To start, you'll need to use the Firefox Developer Edition and the Gecko Profiler WebExtension.

  1. Using the Gecko Profiler, click the "start" recording button in the top right corner.
  2. Do some stuff with React.
  3. When you're finished, click the "Capture Profile" button (then click "Discard and stop").
  4. The profile you've just captured will be opened on the public profiler.firefox.com URL.
  5. To view it in the special React build of the profiler, click the "Publish" button
  6. This will generate a public URL for you, e.g. https://profiler.firefox.com/public/<data>
  7. Copy the portion of the URL after "/public/" and paste into the React profiler URL, e.g. https://dist-nine-murex.now.sh/public/<data>

I realize this is a lot of steps and so probably not many people will want to do this, but in case you did- I wanted to share how :) I'll try to reduce the barrier to playing with this tool in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment