How to capture a CPU profile in Node.js
# 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