perf script’s output is a massive, line-by-line log of every event happening in the kernel and userspace.
Let’s see it in action. Imagine we’re trying to figure out why a simple echo "hello" > /tmp/foo is taking ages.
First, we need to capture some data. We’ll run perf record for a few seconds while we do our slow operation:
sudo perf record -a -g -- sleep 10
The -a means sample across all CPUs, -g enables call graphs (crucial for understanding why something is happening), and -- sleep 10 just keeps perf record running for 10 seconds.
Now, the magic happens when we pipe the raw perf.data output to perf script:
sudo perf script -i perf.data
This will spew out thousands, maybe millions, of lines like this:
0.000000000 0.000000000: 1000000000 Hz: cpu_frequency:1499999999 : (1000000000-0)
0.000000000 0.000000000: 153000000 : cycles: