npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tracex

v1.1.1

Published

A tool for extracting metrics from browser traces

Downloads

5

Readme

tracex

A fast, pluggable utility to extract metric from browser traces.

Screenshot of tracex in a terminal

Features

  • Fast: tracex extracts metrics from large numbers of traces in parallel, and handles large traces gracefully through streaming.
  • Pluggable: tracex allows you to create your own specific metrics, and tweak their definitions. This allows you to experiment with custom metrics, or create your own.
  • Graceful errors: trace handles errors gracefully, allowing you to ignore or fix problems in individual trace files or traces.

✨ Use with wpt-gauntlet for an end-to-end benchmarking solution!

Usage

To get started, you can install tracex locally, or run it using npx:

$ npx tracex --help

tracex can be run on a single profile, or a collection of profiles.

For example, to collect metrics from a collection of traces, we specify the file(s) (via a glob pattern) and the metrics we wish to collect:

$ npx tracex "../wpt-gauntlet/output/react-profile-*" --functions "1"

[traceX] Parsing traces and extracting metrics from 19 files
[traceX] ======= Results =======
fileName,function.1:timeTotal,function.1:samplesPresent,function.1:sampleTotal
../wpt-gauntlet/output/react-profile-0.json,17296,51,70954
../wpt-gauntlet/output/react-profile-10.json,17102,69,68011
../wpt-gauntlet/output/react-profile-11.json,17102,69,68011
../wpt-gauntlet/output/react-profile-12.json,11738,29,66865

...

To see a list of built-in metrics and how they can be configured, run npx tracex --help.

Collecting the traces

To use tracex, you must also have a trace, or a collection of traces. This can be done in several ways:

Using a tool like webpagetest, or wpt-gauntlet

See wpt-gauntlet for more details on how to use wpt-gauntlet to collect a large number of traces in an automated way

Profiling chrome using the performace devtools

Click record and then save the profile to disk

Profiling chrome using chrome://tracing directly

Visiting chrome://tracing in Chrome allows you to customize which categories of metrics are recorded in your trace. This gives you a lot more ability to create and specify custom metrics: Chrome tracing save

The tracing categories relied upon for the built in metrics are:

  • urls, functions: ['disabled-by-default-v8.cpu_profiler']
  • framerate: ['cc', 'benchmark']

See here for a list of categories.

Built in metrics

  • --functions "foo": count the number of samples, and the duration of time spent inside functions that match the name of the given parameter. Can be used to profile specific functions over a large collection of traces.
  • --urls "bar": count the number of samples and total time spent inside functions belonging to a particular URL pattern. For example, if your framework was in a bundle named framework.js, --urls "framework" would count time spent inside this framework.
  • --framerate: collect framerate metrics sampled in this profile.

Custom metrics

Custom metrics can be created using plugins. This can be configured with the --plugins argument on the command line:

$ npx tracex ~/Downloads/Profile-20220508T213500.json --plugins ./plugin/example.plugin.js

[traceX] Parsing traces and extracting metrics from 1 files
[traceX] ======= Results =======
fileName,example:events
/Users/josh_nelson/Downloads/Profile-20220508T213500.json,7734

A plugin consists of a module with a default export, with the following fields:

export default {
  // The name of the plugin
  name: "example",
  // A function that creates the plugin
  plugin: function examplePlugin(config, log) {
    const example = {
      events: 0,
    };

    // Returns the plugin itself
    return {
      // `preExtract` runs first over every event in the trace.
      // This can be used for any pre-computation or setup necessary.
      preExtract: (event) => {},
      // `extract` runs afterwards, again over every event in the trace. Most work should be done here.
      extract: () => {
        // See docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit for documentation on the trace event format.
        example.events++;
      },
      // `report` is used to collect results from the plugin. Metrics have a key:subkey format, so ensure that metrics are namespaced in the object under a specific key.
      report: () => {
        return {
          example,
        };
      },
    };
  },
};

See example.plugin.js for an example plugin.