perf

Performance analysis tools for Linux .

SYNTAX
      perf [--version] [--help] COMMAND [ARGS] 

All perf subcommands need to run as root (sudo)

# show programs that are using the most CPU:
$ sudo perf top

# Sample CPUs at 49% show top symbols:
$ sudo perf top -F 49

# Start COMMAND and profile it:
$ sudo perf record COMMAND

# Profile PID until Ctrl-C is pressed:
$ sudo perf record PID

# Profile every process until Ctrl-C is pressed:
$ sudo perf record -a

# CPU counter statistics for COMMAND
$ sudo perf stat COMMAND

# Detailed CPU counter statistics for COMMAND
$ sudo perf stat -ddd COMMAND

# Various basic CPU statistics system wide:
$ sudo perf stat -e cycles,instructions,cache-misses -a

# Show perf.data in an ncurses browser:
$ sudo perf report

# Trace syscalls system wide:
$ sudo perf trace

# Trace syscalls for PID:
$ sudo perf trace -p PID

# Sample CPU functions for COMMAND at 99 Hzertz:
$ sudo perf record -F 99 COMMAND

# Sample CPU functions for PID until Ctrl-C is pressed:
$ sudo perf record -p PID

# Sample CPU functions for PID for 10 seconds:
$ sudo perf record -p PID sleep 10

# Sample CPU stack traces for PID for 10 seconds:
$ sudo perf record -p PID -g -- sleep 10

# Trace new processes until Ctrl-C is pressed:
$ sudo perf record -e sched:sched_process_exec -a

perf can trace system calls faster than strace.

perf record saves to the perf.data file.

"When someone shows you who they are, believe them the first time ~ Maya Angelou

Related linux commands:

htop - Interactive process viewer.
strace - Trace system calls and signals.
Julia Evans Perf-Zine - Profiling and Tracing (pdf)
Equivalent Windows command: perfmon


Copyright © SS64.com 1999-2018
Some rights reserved