Measure Performance Counters With perf stat

See cycles, instructions, cache misses and context switches for one run.

LinuxProcessesmonitoringperformanceDiagnosticsLow risk
Run perf stat -d ./program to print hardware and software counters after it exits.

01Command

Command
$ perf stat -d ./my-program

02What it does

perf stat reads hardware performance counters around a command, revealing whether a workload is CPU-bound, cache-thrashing or stalling. That low-level visibility is only practical from the command line and is why profiling lives in the terminal.

03Risk

RiskLow risk
Requirementssudo apt install linux-perf
!Warning: Some counters need kernel.perf_event_paranoid relaxed or root; results vary with system load.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: System & Settings

06Related solutions