Node.js AdvancedLesson 92Free preview
Perf_hooks Module
This lesson is part of Node.js · All levels
Summary
This lesson discusses built-in perf_hooks modules for measuring code performance with high precision. You'll use performance.now() for short timing, performance.measureUserAgentSpecificMemory() for memory, and also a histogram to monitor latency. The module also provides an EventLoopDelay monitor to detect a jammed event loop. (Node.js)
Key points
- Performance.now() gives a high-precision timestamp (decimal milliseconds) to measure duration.
- The EventLoopDelay monitor creates a histogram delay event loop (mean, p99) for detecting blocking.
- CreateHistogram measures the duration distribution of operations such as API response time.
- (ELU) shows what percentage of the event loop is busy.
- Performance.mark() and performance.measure() are suitable for measuring the application stage.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.