Exercise 1: Sampling Versus Tracing — Possible Solution ======================================================== TASK Explain the difference between sampling and tracing, and say which one Time Profiler uses and which kind of question each suits. ANSWER - Sampling: the tool looks at the CPU every few milliseconds to see what code is running. - Tracing: the tool records every time a specific event, such as a memory allocation, occurs. - Time Profiler samples: it captures the call stacks of running threads, typically at 1 ms intervals, and builds a statistical profile. WHICH SUITS WHAT - Sampling suits "where does the time go overall?" because a hot function shows up in many samples. It can miss something that runs only briefly between samples. - Tracing suits "how often does this event happen?" because every event is recorded, at the cost of more overhead. CHECK The two definitions and the 1 ms figure come from the chapter's sources. The suitability comments are my inference from those definitions.