Using the Chrome DevTools Audit Feature to Measure and Optimize Performance (Part 1)
Tags: webdev, react, programming, javascript
Published: 2019-01-16 12:59:56

---
title: Using the Chrome DevTools Audit Feature to Measure and Optimize Performance (Part 1)
published: true
tags: web-development,react,programming,javascript
canonical_url: https://medium.com/chingu/using-the-chrome-devtools-audit-feature-to-measure-and-optimize-performance-part-1-868a20bbfde8
---

#### Creating your Performance Tuning Process

![](https://cdn-images-1.medium.com/max/1024/1*ynnaISC0gTdj1_RnWsSv7A.jpeg)<figcaption>Photo by <a href="https://unsplash.com/photos/xnUQO2DwXOo?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Christian Kaindl</a> on <a href="https://unsplash.com/search/photos/measuring?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

In an earlier article, “[React Application Performance Analysis](https://medium.com/chingu/react-application-performance-analysis-part-1-611976a54de7),” we touched on some of the Chrome DevTools features that are useful when analyzing application performance, and described a workflow for performance measurement and tuning.

Lets now take a deeper dive into Chrome DevTools see how the Audit feature can be used to pinpoint and correct performance issues, primarily using these four tools,

- Audit feature of Chrome Developer Tools
- React plugin for Chrome
- [Scientific method](https://en.wikipedia.org/wiki/Scientific_method)
- Your knowledge & experience

As crucial as tools are to easing the “grunt” work associated with any task, what makes the most difference to the outcome is combining your knowledge and experience with a repeatable process. Relying more on these, rather than on the tools, will allow you to swap different tools in and out of the process based on changes in requirements and landscape. It’s also a superior method of expanding your knowledge and experience since it reinforces what you already know to be true and challenges what you think to be true.

Let’s get started!

### The Meteorite Explorer Application

The application we’ll be analyzing is [Meteorite Explorer](https://jdmedlock.github.io/meteorite/). The sole purpose of this application is to present data about meteorite landings from the [Meteorite Landing](https://data.nasa.gov/Space-Science/Meteorite-Landings/gh4g-9sfh) dataset found on Nasa’s Open Data Portal. Information about each of the approximately 46K reported meteorite strikes going back to 301 A.D. are presented in a tabular format along with the capability to search on the name of the landing location.

![](https://cdn-images-1.medium.com/max/1024/1*_8IM2kHOxrLFeB2DuusETg.png)<figcaption>Figure 1 — Meteorite Explorer</figcaption>

Rather than pointing out the flaws in the application as it currently stands, try it out and ask yourself,

1. Are there any areas where performance impacts the [user experience](https://en.wikipedia.org/wiki/User_experience) (i.e., UX)?
2. Is performance consistent across all [use cases](https://en.wikipedia.org/wiki/Use_case), or are there specific ones where it’s particularly impactful?
3. Is performance generally acceptable, or is its impact such that it limits the effectiveness of the application?

The Meteorite Explorer repo is hosted on [GitHub](https://github.com/jdmedlock/meteorite) and the starting point, before any tuning, resides in the branch `feature/01-initial-app`.

### Performance Tuning Workflow

![](https://cdn-images-1.medium.com/max/1024/1*N2lSvZ8bKl1jAxUNJHIbJQ.jpeg)<figcaption>From <a href="http://www.pexels.com">www.pexels.com</a></figcaption>

Our performance tuning workflow is conceptually simple, but like most “simple” things it can be complex to implement and follow. The high-level steps that make up our process, or “workflow,” are,

1. Take a baseline snapshot of performance.
2. Review the snapshot and identify problem areas.
3. Develop ideas for how the application can be changed to improve its performance.
4. Test each idea in isolation and measure performance against the baseline.
5. Choose the idea with the most positive impact, implement it, and create a new performance baseline as part of your production deployment procedure.

At this point, you might be thinking “This process sounds like the Scientific Method!” There is a good reason for this. It’s because it represents the core principles of the Scientific Method — observe, hypothesize, experiment, and refine.

#### Practical Shortcuts

It’s important to point out that there are shortcuts that can be taken to make the process faster. The most obvious is that the review of the original baseline (step #2) may not show any problems. If that is the case, then there’s no need to perform any tuning.

Likewise, you may find there are area’s of concern, but nothing severe enough to justify additional tuning. In this situation, make a record of your observation so you’ll have the information you need to give the problem the attention it deserves if it becomes more impactful. However, take caution if you choose to defer resolving the issue so it doesn’t become another instance of [technical debt](https://en.wikipedia.org/wiki/Technical_debt).

As you are developing ideas (e.g., [hypothesis](https://en.wikipedia.org/wiki/Hypothesis)) for how to correct a problem don’t overanalyze its importance. It’s advisable to be creative when identifying possible solutions but to rely on your knowledge of the situation and application, coupled with the severity of the issue, to create a more focused list of avenues to pursue.

> “It’s okay to use your intuition as a starting point.”

Having a short list of ideas to test is more practical, more efficient, and it follows that it is then more achievable. It’s okay to use your “[intuition](https://en.wikipedia.org/wiki/Intuition)” since a self-correcting process is being followed. If your intuition is incorrect, the process will reveal that the solution didn’t have the desired impact and another is needed.

#### It’s Okay to be Wrong

Also, keep in mind that it is entirely acceptable to be wrong since the magnitude of what we learn from our mistakes is often more significant than what we learn from success. One of the strengths of the observe-hypothesize-test-refine approach is it both catches and builds upon incorrect ideas.

> “You build on failure. You use it as a stepping stone. Close the door on the past. You don’t try to forget the mistakes, but you don’t dwell on it. You don’t let it have any of your energy, or any of your time, or any of your space.” … Johnny Cash

There is no disgrace in being wrong. Any stigma should be the result of repeating the same mistakes over and over and over again.

### Baseline the Application

![](https://cdn-images-1.medium.com/max/1024/1*ST1O3igp4dXRedMVmPsKRg.jpeg)<figcaption>Photo by <a href="https://unsplash.com/photos/7l8z2pIbHYk?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sarandy Westfall</a> on <a href="https://unsplash.com/search/photos/snapshot?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

Just as a photograph captures the image of a particular moment in time the baseline captures a profile of the performance of an application at a specific point in its life. The baselines purpose is to establish a position from which the effect of changes can be analyzed to determine if they improved or degraded the original issue.

> “If you can’t measure it, you can’t manage it.” … Peter F. Drucker

In a previous [article](https://goo.gl/WvczNT), we examined how to use basic features of Chrome Developer Tools and the React Component Profiler to measure application performance. However, over the past year, two changes have come about which alter the tools we’ll now be using.

First, React release 16 [deprecated](https://reactjs.org/docs/perf.html) the React Component Profiler, and it is instead recommended that native browser profiling tools should be used. Second, the ‘Audit’ feature [added](https://goo.gl/nu5cfd) Google [Lighthouse](https://developers.google.com/web/tools/lighthouse/) to Chrome’s Developer Tools in version 60.

#### Capturing the Baseline

To create a baseline snapshot first start Developer Tools ( _Option+Command+I_ on MacOS) and then select ‘Audits’ item from the ‘\>\>’ menu.

![](https://cdn-images-1.medium.com/max/1024/1*HYTIbvPWYqx2pqrFmwzaGA.png)<figcaption>Figure 2 — Selecting the Audit feature (aka Lighthouse) in Chrome Dev Tools</figcaption>

The Audit feature displays various capabilities and options within the Dev Tools pane in the browser window. The ‘Device’ section lists the types of devices used for the audit, ‘Audits’ indicates which audit to perform, and the ‘Throttling’ section defines which network conditions will be simulated.

For this discussion select ‘Desktop’, ‘Performance’, and ‘Simulated Fast 3G, 4x CPU slowdown’, and click the ‘Run audits’ button at the bottom of the pane.

![](https://cdn-images-1.medium.com/max/1024/1*plhF42GbxvQlMJvQI0h77g.png)<figcaption>Figure 3 — Audit Feature Options</figcaption>

#### Running the Performance Audit

![](https://cdn-images-1.medium.com/max/1024/1*-fK2Wdj9sCT0mwvCwEYlSA.png)<figcaption>Figure 4 — Audit Performance Overview</figcaption>

The Performance Audit takes some time to run, so be patient. Once the audit has completed the results will be displayed in the Audit pane and are divided into four categories,

> Metrics

The first part of the Results section provides an indicator for the health of key performance measures, along with an overall score representing aggregate performance. Each metric consists of a standard red-yellow-green health indicator and its elapsed time. Hovering over an item will display an overview and a link to more information.

The ‘View Trace’ button at the end of this section displays a trace of the activity performed by, and for, the application. Advantageous is the fact that screenshots are included showing the state of the UI along the activity timeline.

![](https://cdn-images-1.medium.com/max/710/1*Bbbo8JoUPaPwV3pvp2mKlg.png)<figcaption>Figure 5 — Audit Metrics Trace Output</figcaption>

> Opportunities

The Opportunities part of the Metrics section provides a list of “quick wins” — ways you can improve the application by optimizing resource consumption. Each opportunity displays its anticipated savings and clicking on it will reveal an overview, a link to additional information, and supplemental information.

![](https://cdn-images-1.medium.com/max/710/1*_AZ3Sgt7GSlWgC0v1Uu9vA.png)<figcaption>Figure 6 — Audit Opportunity</figcaption>

> Diagnostics

Diagnostics provides additional areas impacting the application’s performance. Each diagnostic consists of a red or yellow severity indicator as well as an associated measure. Like other Audit components, clicking on a diagnostic will display an overview, supplemental metrics, and links to additional information.

![](https://cdn-images-1.medium.com/max/710/1*fLH3Bsxu17AjJ9GSEu2PgA.png)<figcaption>Figure 7 — Audit Diagnostics</figcaption>

> Passed Audits

The Metrics section not only provides an overview of what’s went wrong with the application but also what went right. ‘Passed audits’ lists successfully completed tests, and as before, clicking on an audit item provides more information.

![](https://cdn-images-1.medium.com/max/710/1*8slErvT8uoICmhUmOZuHcw.png)<figcaption>Figure 8 — Passed Audits</figcaption>

#### Saving the Baseline

Keep in mind that the Performance Audit will produce slightly different results when running on different computers, and even when running on the same machine, but at different times. This is one reason why it’s essential to save the baseline.

At this point, we’re not going to worry about how to interpret the results of the performance audit. We’ll leave that for the next section. However, the audit results should be saved to establish a new baseline.

![](https://cdn-images-1.medium.com/max/546/1*x5DvxxF0mpF-TmCK0PTryw.png)<figcaption>Figure 9 — Audit Download button</figcaption>

Click on the Download button and select the file name and location for the Audit’s JSON file. Since performance tuning requires multiple baselines, a descriptive file name must be used, including the creation date and time. In addition, it’s a good idea to store these in a permanent location, like a Google Drive since at the very least the baseline for your current production release will need to be retained.

To view a saved Audit report open a browser tab to the URL [https://googlechrome.github.io/lighthouse/viewer/](https://googlechrome.github.io/lighthouse/viewer/) and then drag and drop the previously saved JSON file into the viewer window.

### Wrapping It Up

![](https://cdn-images-1.medium.com/max/1024/1*9vy0weDNJN9kc_K13r4D6g.jpeg)<figcaption>Photo by <a href="https://unsplash.com/photos/bbXaYbKWnjw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">NEW DATA SERVICES</a> on <a href="https://unsplash.com/search/photos/process?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

Success isn’t the result of luck — it is the consequence of understanding the problem at hand, having a good set of tools and the knowledge of how to properly use them, and creating a plan for achieving the desired objective. Another vital component of the process is accepting that the plan may need to be adjusted as new information is discovered.

In this article, we’ve presented questions to help frame the application performance problem, defined a performance tuning, and shown how to use the Performance Audit feature of Chrome Developer Tools to create a performance baseline.

In Part 2 — Tuning the Application, we’ll demonstrate how to use these to tune the Meteorite Explorer application to improve the user experience.

**_Disclosure_** : This article was based on an earlier article, “[Using the Chrome DevTools Audit Feature to Measure and Optimize Performance](https://medium.com/chingu/get-blinded-by-science-and-boost-application-performance-b5afd64e34d4)” which has been refactored into two parts.

* * *