Created
September 22, 2025 06:36
-
-
Save sgrodzicki/f51992ed99218a20f3c9793099cc0a75 to your computer and use it in GitHub Desktop.
How to capture a CPU profile in Node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Copy of https://daniellockyer.com/how-to-capture-a-cpu-profile-in-nodejs/ | |
| # Find the process ID of the Node program | |
| ps -H aux | |
| # Enter the Node inspector | |
| node inspect -p <pid> | |
| # Start profiling: | |
| profile | |
| # Wait until you've captured enough of a timeframe | |
| # Stop profiling: | |
| profileEnd | |
| # Save the profile: | |
| profiles[0].save(filepath = 'node.cpuprofile') | |
| # Exit the Node inspector: | |
| Ctrl-d | |
| # curl the file to flamegraphs.com (my service): | |
| curl -F 'file=@node.cpuprofile' https://flamegraphs.com/collect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment