Rethinking of CPU profile analysis and processing. Focused on profiles and logs of any size collected in V8 runtimes: Node.js, Deno and Chromium browsers.
Supported formats:
- V8 CPU profile (.cpuprofile)
- V8 log preprocessed with --preprocess (.json)
- Chromium Performance Profile format (.json)
- Edge Enhanced Performance Traces (.devtools)
STATUS: MVP
The project is at an early stage of development. Some things have yet to be added and polished. Feel free to create an issue if you found a bug or have an idea.
Head to the viewer on GitHub pages, open a file in one of supported formats or drop it on the page.
![Demo](https://private-user-images.githubusercontent.com/270491/323440897-ea4d54b7-8d37-456a-8db3-628a1da7df3e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI2OTQxNjQsIm5iZiI6MTcyMjY5Mzg2NCwicGF0aCI6Ii8yNzA0OTEvMzIzNDQwODk3LWVhNGQ1NGI3LThkMzctNDU2YS04ZGIzLTYyOGExZGE3ZGYzZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODAzJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwM1QxNDA0MjRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT05YjYxMzAwMjYzNjg1YmM1NjMxMmIwNTJiZGY4YjI4OGVjNzQxNmNmMjVlZWVjOGJkMzZiNDBhNTk1NThmZWY5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.pR6JWnuLJqLhLpajsnvXMYEZgFh0FW4iNFlNINmx1ME)
CLI allows to generate a report (an viewer with embedded data) from a profile file.
To use CLI install cpupro
globally using npm install -g cpupro
, or use npx cpupro
.
- open viewer without embedded data in default browser:
cpupro
- open viewer with
test.cpuprofile
data embedded:cpurpro test.cpuprofile
- open viewer with data embedded from
stdin
:cpupro - <test.cpuprofile
cat test.cpuprofile | cpupro -
- get usage information:
Usage: cpupro [filepath] [options] Options: -f, --filename <filename> Specify a filename for a report; should ends with .htm or .html, otherwise .html will be added -h, --help Output usage information -n, --no-open Prevent open a report in browser, the report will be written to file -o, --output-dir <path> Specify an output path for a report (current working dir by default) -v, --version Output version
Main cpupro
API is similar to console.profile()
/ console.profileEnd()
with an exception that the profileEnd()
method does nothing but returns API for saving data to a file or generating a report:
const profiler = require('cpupro');
profiler.profile('profileName');
// ... do something
const profile = profiler.profileEnd('profileName');
// write data to .cpuprofile file
profile.writeToFile('./path/to/demo.cpuprofile');
// or write a report (the viewer with embedded data) to file
profile.report.writeToFile('report.html');
// or open the report in a browser
profile.report.open();
It is allowed to have several profiles being recorded at once. It's possible to use a reference to profile record API instead of a profile name:
const profiler = require('cpupro');
const profile = profiler.profile();
// ... do something
// end profiling and open a report in a browser
profile.profileEnd().openReport();
Record profile, generate report and open it in a browser:
node --require cpupro path/to/script.js
Record profile, generate report and write into a file:
node --require cpupro/file path/to/script.js
# or
node --require cpupro/file/report path/to/script.js
Record profile and write it into .cpuprofile
file:
node --require cpupro/file/data path/to/script.js
MIT