Profiling with perf
From PostgreSQL wiki
To profile the system for a specific length of time, for example 60 seconds:
perf record -a -g -s sleep 60
To profile the system for the duration of a command:
perf record -a -g -s -- pg_ctl -D pgdata start
To profile in real time:
By default this will generate a perf.data file in the current working directory.
By default perf will look for perf.data in the current working directory.
perf report -n
Annotated source code:
perf annotate -l -P
perf script -L
The perf tool is available on recent Linux distributions such as:
- RedHat Linux Enterprise 6
- Debian Squeeze: add the linux-tools package.
It may be built and installed from the linux source code in the tools/perf subdirectory.