vitest-profiler-plugin
v1.0.8
Published
A vitest plugin to profile test execution time.
Readme
vitest-profiler-plugin
A Vitest plugin to profile test execution time.
Installation
npm install --save-dev vitest-profiler-pluginUsage
Add the plugin to your vitest.config.js file:
import { defineConfig } from 'vitest/config'
import { profilerPlugin } from 'vitest-profiler-plugin'
export default defineConfig({
plugins: [
profilerPlugin(),
]
})What it does
This plugin uses the v8-profiler-next library to generate CPU profiles for your tests.
For each test, a .cpuprofile file is generated in the test-profile directory. The file path mirrors the test file path and the test's suite structure.
Disabling the plugin
You can disable the plugin by setting the VITEST_PROFILER_DISABLE environment variable to a truthy value.
VITEST_PROFILER_DISABLE=1 vitestViewing the profiles
To examine the generated profile:
- Open Chrome and navigate to
chrome://inspect. - Click "Open dedicated DevTools for Node".
- Select the "Performance" tab.
- Click "Load profile" and import your
.cpuprofilefile.
