One of the easiest ways to track performance regressions in your JavaScript applications is to use Vitest's  API. It lets you write benchmarks as

Using Vitest bench to track performance regressions in your CI

submited by
Style Pass
2023-11-21 14:00:15

One of the easiest ways to track performance regressions in your JavaScript applications is to use Vitest's API. It lets you write benchmarks as easily as unit tests:

The problem that we now face is that the results are inconsistent between runs. Running the command multiple times in a CI/CD runner or on your machine will yield different results. Thus it will be hard to spot performance regressions with confidence.

This is where using CodSpeed comes in handy. CodSpeed provides a way to run benchmarks in a consistent manner, and thus detect performance regressions with confidence.

We can see that CodSpeed has been detected and that the benchmarks have been run. For the moment we can see the default output of Vitest's API.

To generate performance reports, you need to run the benchmarks in your CI. This allows CodSpeed to detect the CI environment and properly configure the instrumented environment.

The first step is to log in to CodSpeed and import the repository you want to track. You can find more information about this in the CodSpeed documentation.

Leave a Comment