Skip to main content
btheo.com btheo.com > press start to play
NEW POST: NODE.JS SECURITY 2025 OPEN FOR FREELANCE 10+ YEARS EXP REACT × NODE × AWS NEW POST: NODE.JS SECURITY 2025 OPEN FOR FREELANCE 10+ YEARS EXP REACT × NODE × AWS
TIL · 18 FEB 2026 · NOTE #023 ESC
TIL NOTE #023

Profile Before You Optimize

You’re sure the database query is slow. You optimize it. Query time drops 50ms. But the request is still slow.

The bottleneck wasn’t the query. It was JSON serialization.

Get the real answer with profiling:

Terminal window
node --prof server.js
# Make requests...
node --prof-process isolate-*.log > profile.txt

Or use clinic.js for flame graphs:

Terminal window
clinic doctor -- node server.js

Or the Node.js inspector:

Terminal window
node --inspect server.js
# chrome://inspect

The thing you’re sure is slow usually isn’t. Find the actual bottleneck. Premature optimization wastes weeks for 2% gains.

Measure first. Optimize once. Ship faster.