Profiling

Using Rsdoctor

Rsdoctor is a build analysis tool that can visually display the compilation time of each loaders and plugins.

When you need to debug Rstest's build outputs or build processes, you can use Rsdoctor for troubleshooting.

Quick start

In Rstest, you can enable Rsdoctor analysis as follows:

  1. Install the Rsdoctor plugin:
npm
yarn
pnpm
bun
npm add @rsdoctor/rspack-plugin -D
  1. Add RSDOCTOR=true env variable before the CLI command:
package.json
{
  "scripts": {
    "test:rsdoctor": "RSDOCTOR=true rstest run"
  }
}

As Windows does not support the above usage, you can also use cross-env to set environment variables. This ensures compatibility across different systems:

package.json
{
  "scripts": {
    "test:rsdoctor": "cross-env RSDOCTOR=true rstest run"
  },
  "devDependencies": {
    "cross-env": "^7.0.0"
  }
}

After running the above commands, Rstest will automatically register the Rsdoctor plugin, and after the build is completed, it will open the build analysis page. For complete features, please refer to Rsdoctor document.

rsdoctor-rstest-outputs

CPU profiling

Samply

Note: In order to be able to profiling the Node.js side code in macOS, Node.js v22.16+ is required.

Samply supports performance analysis for both Rstest main process and test process simultaneously. You can perform a complete performance analysis through the following steps:

Run the following command to start performance analysis::

samply record -- node --perf-prof --perf-basic-prof --interpreted-frames-native-stack {your_node_modules_folder}/@rstest/core/bin/rstest.js

After the command execution, the analysis results will automatically open in the Firefox Profiler.

Rstest’s JavaScript typically runs in the Node.js thread. Select the Node.js thread to view the time distribution on the Node.js side.

rstest-samply-profiling