Node.js · Senior · Question 9 of 75
How do you find which functions use the most CPU in production-like conditions?
- 1Read
process.cpuUsage()once at startup - ✓Correct answer: Record a CPU profile (
--cpu-profor the inspector) under realistic load and look at a flame graph - 3Add
console.timeto every function
Explanation
Profiles show where time goes, including GC and native code. Generate load with a tool like autocannon or k6, since idle profiles show nothing useful.