← Back to Node.js performance mapbuilt-in
🎯
Node.js Performance
perf_hooks Timing
Use built-in precision timers to measure exact code paths.
Detailed Description
The perf_hooks module gives high precision measurements inside Node without adding external dependencies. You can mark the start and end of important work and measure the exact duration.
This is best for timing business-level operations such as DB writes, cache reads, payment calls, rendering, or job steps. Keep labels consistent so the data can become metrics later.
Mental Model
performance.mark(start) -> run work -> performance.measure(name)
When To Use
- ->Measure one route or function without external tools
- ->Time DB, cache, or external API segments
- ->Add low-overhead production timings
Tools: perf_hooks PerformanceObserver, performance.timerify
perf-hooks.js
Live Editor
Loading...
Output
Run code to see output...