Master the fundamental concepts of profiling & measurement through this focused micro-challenge.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksBrendan Gregg's production performance work at Netflix and Sun starts with simple wall-clock timing, then perf stat, then deeper tools. Guessing where time goes wastes weeks. A three-line time run, a perf stat pass for cycles and cache misses, and hyperfine for repeated comparisons form the baseline toolkit every systems engineer keeps on hand.
time reports elapsed, user, and system seconds for one run. perf stat samples hardware counters without modifying your binary. hyperfine warms up, runs many iterations, and prints mean plus standard deviation so you can see noise.
bashLoading…
Keep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will benchmark a small C program with time, perf stat, and hyperfine, then print a short comparison table. This exercise asks you to treat measurement as the first optimization step, not an afterthought.
time, perf stat and hyperfine answer different questions: where the wall-clock time went (user, system, or waiting), how efficiently the CPU ran (clock speed, instructions per cycle, branch misses), and how stable repeated measurements are. Real runs are never repeatable, so this task starts from recorded measurements and does the analysis these tools print, in exact integer arithmetic.
cLoading…
N us below 1 ms, N.N ms below 1 s, and N.NN s otherwise, truncated (not rounded). (more than one core busy) if USER + SYS > REAL, or (mostly waiting: I/O or sleep) if USER + SYS < REAL / 2.sum((t − mean)^2) / (n − 1); 0 for one run), min and max. Warn when sd × 10 > mean.time: expected REAL USER SYS (us), perf: expected TASK_CLOCK_US CYCLES INSTRUCTIONS BRANCHES BRANCH_MISSES, bench NAME: no positive run times, and summary: need at least two benchmarks.cLoading…
Input:
cLoading…
Output:
cLoading…
Hidden tests cover multi-threaded and I/O-bound time lines, low-IPC and high-miss perf counters, a single-run benchmark, sub-millisecond runs, a summary across three benchmarks, and malformed lines.