A small practical repo to explore Node.js Event Loop performance using perf_hooks and eventLoopUtilization.
Note: For detailed explanations of each demo, including the code logic and expected behavior, see the
00-readme.mdfile inside thecodes/folder.
This repository demonstrates:
- Measuring Event Loop utilization (ELU)
- Monitoring tick time and mean delay
- Understanding how heavy synchronous tasks affect the event loop
- Dividing heavy tasks into chunks to prevent blocking
git clone https://github.com/Maryam-Skaik/nodejs-eventloop-perf.git
cd nodejs-eventloop-perf
npm installRequires Node.js 14+
1. Event Loop Utilization
demo-eventloop-utilization.js
Shows ELU metrics: idle, active, utilization, and mean delay. Helps detect ticks overloaded by heavy tasks or microtasks.
2. Chunking Heavy Code
demo-heavy-task-chunks.js
Demonstrates splitting a heavy synchronous loop into smaller chunks using setImmediate to reduce tick length and prevent starvation.
- utilization: Percentage of time the loop is busy.
- mean delay: Average delay between ticks.
- Tick time: Actual time a tick took.
- Tick capacity: Maximum amount of work a tick can handle before deferring tasks to the next tick.
Run a demo:
node codes/demo-eventloop-utilization.js
node codes/demo-heavy-task-chunks.js- Understand how Node.js event loop handles heavy tasks
- Measure and interpret ELU metrics in real code
- Learn how to split tasks to avoid blocking the loop
This project is licensed under the MIT License
© 2025 Maryam Skaik
Maryam Skaik
GitHub Profile | LinkedIn