Book Image

Node.js High Performance

By : Diogo Resende
Book Image

Node.js High Performance

By: Diogo Resende

Overview of this book

Table of Contents (14 chapters)

Chapter 4. CPU Profiling

Profiling is boring, but it's a good form of software analysis where you measure resource usage. This usage is measured over time and sometimes under specific workloads. Resources can mean anything the application is using, be it memory, disk, network, or processor. More specifically, CPU profiling allows you to analyze how and how much your functions use the processor. You can also analyze the opposite—the non-usage of the processor, or the idle time.

Node.js is not primarily meant for continuous CPU-intensive tasks, and sometimes, for profiling, it is important to identify the methods of the intensive task that are holding to the processor and keeping other tasks from performing better. You may find huge call stacks continuously occupying the processor or repetitive and recursive tasks not ending as you expected. There are several techniques, such as splitting and scheduling tasks instead of continuously running them as they block the event loop.

You may ask why...