Bird
0
0

Why does Node.js CPU profiling use sampling instead of tracing every function call?

hard📝 Conceptual Q10 of 15
Node.js - Debugging and Profiling
Why does Node.js CPU profiling use sampling instead of tracing every function call?
ATracing is only used for memory profiling, not CPU profiling
BTracing every call is impossible in JavaScript
CSampling reduces overhead and avoids slowing down the app significantly
DSampling provides exact timing for each function call
Step-by-Step Solution
Solution:
  1. Step 1: Understand profiling methods

    Sampling collects CPU usage data periodically to reduce performance impact.
  2. Step 2: Exclude incorrect statements

    Tracing every call is possible but costly; sampling does not provide exact timing; tracing is not limited to memory profiling.
  3. Final Answer:

    Sampling reduces overhead and avoids slowing down the app significantly -> Option C
  4. Quick Check:

    CPU profiling uses sampling to reduce overhead [OK]
Quick Trick: Sampling balances detail and performance in CPU profiling [OK]
Common Mistakes:
  • Thinking tracing every call is always used
  • Believing sampling gives exact timings
  • Confusing tracing with memory profiling only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes