2009-04-20 21:52:29 +08:00
|
|
|
perf-stat(1)
|
2008-04-16 04:39:31 +08:00
|
|
|
============
|
2009-04-20 21:52:29 +08:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
|
|
|
perf-stat - Run a command and gather performance counter statistics
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
|
|
|
[verse]
|
2010-12-01 09:57:19 +08:00
|
|
|
'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command>
|
|
|
|
'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
|
2009-04-20 21:52:29 +08:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
|
|
|
This command runs a command and gathers performance counter statistics
|
|
|
|
from it.
|
|
|
|
|
|
|
|
|
|
|
|
OPTIONS
|
|
|
|
-------
|
|
|
|
<command>...::
|
|
|
|
Any command you can specify in a shell.
|
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
-e::
|
|
|
|
--event=::
|
2009-06-06 20:56:33 +08:00
|
|
|
Select the PMU event. Selection can be a symbolic event name
|
|
|
|
(use 'perf list' to list all events) or a raw PMU
|
|
|
|
event (eventsel+umask) in the form of rNNN where NNN is a
|
|
|
|
hexadecimal event descriptor.
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
-i::
|
2010-05-12 16:40:01 +08:00
|
|
|
--no-inherit::
|
|
|
|
child tasks do not inherit counters
|
2009-06-04 22:33:00 +08:00
|
|
|
-p::
|
|
|
|
--pid=<pid>::
|
2012-02-09 00:32:52 +08:00
|
|
|
stat events on existing process id (comma separated list)
|
2010-12-01 09:57:19 +08:00
|
|
|
|
|
|
|
-t::
|
|
|
|
--tid=<tid>::
|
2012-02-09 00:32:52 +08:00
|
|
|
stat events on existing thread id (comma separated list)
|
2010-12-01 09:57:19 +08:00
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
-a::
|
2010-12-01 09:57:19 +08:00
|
|
|
--all-cpus::
|
|
|
|
system-wide collection from all CPUs
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2009-08-07 16:18:39 +08:00
|
|
|
-c::
|
2010-12-01 09:57:19 +08:00
|
|
|
--scale::
|
|
|
|
scale/normalize counter values
|
|
|
|
|
|
|
|
-r::
|
|
|
|
--repeat=<n>::
|
2013-03-02 02:02:27 +08:00
|
|
|
repeat command and print average + stddev (max: 100). 0 means forever.
|
2009-04-20 21:52:29 +08:00
|
|
|
|
perf stat: add perf stat -B to pretty print large numbers
It is hard to read very large numbers so provide an option to perf stat
to separate thousands using a separator. The patch leverages the locale
support of stdio. You need to set your LC_NUMERIC appropriately, for
instance LC_NUMERIC=en_US.UTF8. You need to pass -B to activate this
feature. This way existing scripts parsing the output do not need to be
changed. Here is an example.
$ perf stat noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.347031 task-clock-msecs # 0.998 CPUs
61 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
118 page-faults # 0.000 M/sec
4,138,410,900 cycles # 2070.917 M/sec (scaled from 70.01%)
2,062,650,268 instructions # 0.498 IPC (scaled from 70.01%)
2,057,653,466 branches # 1029.678 M/sec (scaled from 70.01%)
40,267 branch-misses # 0.002 % (scaled from 30.04%)
2,055,961,348 cache-references # 1028.831 M/sec (scaled from 30.03%)
53,725 cache-misses # 0.027 M/sec (scaled from 30.02%)
2.001393933 seconds time elapsed
$ perf stat -B noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.297883 task-clock-msecs # 0.998 CPUs
59 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
119 page-faults # 0.000 M/sec
4,131,380,160 cycles # 2067.450 M/sec (scaled from 70.01%)
2,059,096,507 instructions # 0.498 IPC (scaled from 70.01%)
2,054,681,303 branches # 1028.216 M/sec (scaled from 70.01%)
25,650 branch-misses # 0.001 % (scaled from 30.05%)
2,056,283,014 cache-references # 1029.017 M/sec (scaled from 30.03%)
47,097 cache-misses # 0.024 M/sec (scaled from 30.02%)
2.001391016 seconds time elapsed
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4bf28fe8.914ed80a.01ca.fffff5f5@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-18 21:00:01 +08:00
|
|
|
-B::
|
2010-12-01 09:57:19 +08:00
|
|
|
--big-num::
|
perf stat: add perf stat -B to pretty print large numbers
It is hard to read very large numbers so provide an option to perf stat
to separate thousands using a separator. The patch leverages the locale
support of stdio. You need to set your LC_NUMERIC appropriately, for
instance LC_NUMERIC=en_US.UTF8. You need to pass -B to activate this
feature. This way existing scripts parsing the output do not need to be
changed. Here is an example.
$ perf stat noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.347031 task-clock-msecs # 0.998 CPUs
61 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
118 page-faults # 0.000 M/sec
4,138,410,900 cycles # 2070.917 M/sec (scaled from 70.01%)
2,062,650,268 instructions # 0.498 IPC (scaled from 70.01%)
2,057,653,466 branches # 1029.678 M/sec (scaled from 70.01%)
40,267 branch-misses # 0.002 % (scaled from 30.04%)
2,055,961,348 cache-references # 1028.831 M/sec (scaled from 30.03%)
53,725 cache-misses # 0.027 M/sec (scaled from 30.02%)
2.001393933 seconds time elapsed
$ perf stat -B noploop 2
noploop for 2 seconds
Performance counter stats for 'noploop 2':
1998.297883 task-clock-msecs # 0.998 CPUs
59 context-switches # 0.000 M/sec
0 CPU-migrations # 0.000 M/sec
119 page-faults # 0.000 M/sec
4,131,380,160 cycles # 2067.450 M/sec (scaled from 70.01%)
2,059,096,507 instructions # 0.498 IPC (scaled from 70.01%)
2,054,681,303 branches # 1028.216 M/sec (scaled from 70.01%)
25,650 branch-misses # 0.001 % (scaled from 30.05%)
2,056,283,014 cache-references # 1029.017 M/sec (scaled from 30.03%)
47,097 cache-misses # 0.024 M/sec (scaled from 30.02%)
2.001391016 seconds time elapsed
Cc: David S. Miller <davem@davemloft.net>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
LKML-Reference: <4bf28fe8.914ed80a.01ca.fffff5f5@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-05-18 21:00:01 +08:00
|
|
|
print large numbers with thousands' separators according to locale
|
|
|
|
|
2010-05-28 18:00:01 +08:00
|
|
|
-C::
|
|
|
|
--cpu=::
|
2010-12-01 09:57:19 +08:00
|
|
|
Count only on the list of CPUs provided. Multiple CPUs can be provided as a
|
|
|
|
comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
|
2010-05-28 18:00:01 +08:00
|
|
|
In per-thread mode, this option is ignored. The -a option is still necessary
|
|
|
|
to activate system-wide monitoring. Default is to count on all CPUs.
|
|
|
|
|
2010-11-16 17:05:01 +08:00
|
|
|
-A::
|
|
|
|
--no-aggr::
|
|
|
|
Do not aggregate counts across all monitored CPUs in system-wide mode (-a).
|
|
|
|
This option is only valid in system-wide mode.
|
|
|
|
|
2010-12-01 09:57:19 +08:00
|
|
|
-n::
|
|
|
|
--null::
|
|
|
|
null run - don't start any counters
|
|
|
|
|
|
|
|
-v::
|
|
|
|
--verbose::
|
|
|
|
be more verbose (show counter open errors, etc)
|
|
|
|
|
perf stat: Add csv-style output
This patch adds an option (-x/--field-separator) to print counts using a
CSV-style output. The user can pass a custom separator. This makes it very easy
to import counts directly into your favorite spreadsheet without having to
write scripts.
Example:
$ perf stat --field-separator=, -a -- sleep 1
4009.961740,task-clock-msecs
13,context-switches
2,CPU-migrations
189,page-faults
9596385684,cycles
3493659441,instructions
872897069,branches
41562,branch-misses
22424,cache-references
1289,cache-misses
Works also in non-aggregated mode:
$ perf stat -x , -a -A -- sleep 1
CPU0,1002.526168,task-clock-msecs
CPU1,1002.528365,task-clock-msecs
CPU2,1002.523360,task-clock-msecs
CPU3,1002.519878,task-clock-msecs
CPU0,1,context-switches
CPU1,5,context-switches
CPU2,5,context-switches
CPU3,6,context-switches
CPU0,0,CPU-migrations
CPU1,1,CPU-migrations
CPU2,0,CPU-migrations
CPU3,1,CPU-migrations
CPU0,2,page-faults
CPU1,6,page-faults
CPU2,9,page-faults
CPU3,174,page-faults
CPU0,2399439771,cycles
CPU1,2380369063,cycles
CPU2,2399142710,cycles
CPU3,2373161192,cycles
CPU0,872900618,instructions
CPU1,873030960,instructions
CPU2,872714525,instructions
CPU3,874460580,instructions
CPU0,221556839,branches
CPU1,218134342,branches
CPU2,218161730,branches
CPU3,218284093,branches
CPU0,18556,branch-misses
CPU1,1449,branch-misses
CPU2,3447,branch-misses
CPU3,12714,branch-misses
CPU0,8330,cache-references
CPU1,313844,cache-references
CPU2,47993728,cache-references
CPU3,826481,cache-references
CPU0,272,cache-misses
CPU1,5360,cache-misses
CPU2,1342193,cache-misses
CPU3,13992,cache-misses
This second version adds the ability to name a separator and uses
field-separator as the long option to be consistent with perf report.
Commiter note: Since we enabled --big-num by default in 201e0b0 and -x can't be
used with it, we need to notice if the user explicitely enabled or disabled -B,
add code to disable big_num if the user didn't explicitely set --big_num when
-x is used.
Cc: David S. Miller <davem@davemloft.net>
Cc: Frederik Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: paulus@samba.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <robert.richter@amd.com>
LKML-Reference: <4cf68aa7.0fedd80a.5294.1203@mx.google.com>
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2010-12-02 00:49:05 +08:00
|
|
|
-x SEP::
|
|
|
|
--field-separator SEP::
|
|
|
|
print counts using a CSV-style output to make it easy to import directly into
|
|
|
|
spreadsheets. Columns are separated by the string specified in SEP.
|
|
|
|
|
perf tool: Add cgroup support
This patch adds the ability to filter monitoring based on container groups
(cgroups) for both perf stat and perf record. It is possible to monitor
multiple cgroup in parallel. There is one cgroup per event. The cgroups to
monitor are passed via a new -G option followed by a comma separated list of
cgroup names.
The cgroup filesystem has to be mounted. Given a cgroup name, the perf tool
finds the corresponding directory in the cgroup filesystem and opens it. It
then passes that file descriptor to the kernel.
Example:
$ perf stat -B -a -e cycles:u,cycles:u,cycles:u -G test1,,test2 -- sleep 1
Performance counter stats for 'sleep 1':
2,368,667,414 cycles test1
2,369,661,459 cycles
<not counted> cycles test2
1.001856890 seconds time elapsed
Signed-off-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <4d590290.825bdf0a.7d0a.4890@mx.google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2011-02-14 17:20:01 +08:00
|
|
|
-G name::
|
|
|
|
--cgroup name::
|
|
|
|
monitor only in the container (cgroup) called "name". This option is available only
|
|
|
|
in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
|
|
|
|
container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
|
|
|
|
can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
|
|
|
|
to first event, second cgroup to second event and so on. It is possible to provide
|
|
|
|
an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
|
|
|
|
corresponding events, i.e., they always refer to events defined earlier on the command
|
|
|
|
line.
|
|
|
|
|
2011-08-16 04:22:33 +08:00
|
|
|
-o file::
|
2011-09-08 07:14:00 +08:00
|
|
|
--output file::
|
2011-08-16 04:22:33 +08:00
|
|
|
Print the output into the designated file.
|
|
|
|
|
|
|
|
--append::
|
|
|
|
Append to the output file designated with the -o option. Ignored if -o is not specified.
|
|
|
|
|
2011-09-08 07:14:00 +08:00
|
|
|
--log-fd::
|
|
|
|
|
|
|
|
Log output to fd, instead of stderr. Complementary to --output, and mutually exclusive
|
|
|
|
with it. --append may be used here. Examples:
|
|
|
|
3>results perf stat --log-fd 3 -- $cmd
|
|
|
|
3>>results perf stat --log-fd 3 --append -- $cmd
|
|
|
|
|
2012-10-23 19:40:14 +08:00
|
|
|
--pre::
|
|
|
|
--post::
|
|
|
|
Pre and post measurement hooks, e.g.:
|
|
|
|
|
|
|
|
perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage
|
2011-09-08 07:14:00 +08:00
|
|
|
|
perf stat: Add interval printing
This patch adds a new printing mode for perf stat. It allows interval
printing. That means perf stat can now print event deltas at regular
time interval. This is useful to detect phases in programs.
The -I option enables interval printing. It expects an interval duration
in milliseconds. Minimum is 100ms. Once, activated perf stat prints
events deltas since last printout. All modes are supported.
$ perf stat -I 1000 -e cycles noploop 10
noploop for 10 seconds
# time counts events
1.000109853 2,388,560,546 cycles
2.000262846 2,393,332,358 cycles
3.000354131 2,393,176,537 cycles
4.000439503 2,393,203,790 cycles
5.000527075 2,393,167,675 cycles
6.000609052 2,393,203,670 cycles
7.000691082 2,393,175,678 cycles
The output format makes it easy to feed into a plotting program such as
gnuplot when the -I option is used in combination with the -x option:
$ perf stat -x, -I 1000 -e cycles noploop 10
noploop for 10 seconds
1.000084113,2378775498,cycles
2.000245798,2391056897,cycles
3.000354445,2392089414,cycles
4.000459115,2390936603,cycles
5.000565341,2392108173,cycles
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1359460064-3060-3-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-01-29 19:47:44 +08:00
|
|
|
-I msecs::
|
|
|
|
--interval-print msecs::
|
2013-02-06 22:46:02 +08:00
|
|
|
Print count deltas every N milliseconds (minimum: 100ms)
|
perf stat: Add interval printing
This patch adds a new printing mode for perf stat. It allows interval
printing. That means perf stat can now print event deltas at regular
time interval. This is useful to detect phases in programs.
The -I option enables interval printing. It expects an interval duration
in milliseconds. Minimum is 100ms. Once, activated perf stat prints
events deltas since last printout. All modes are supported.
$ perf stat -I 1000 -e cycles noploop 10
noploop for 10 seconds
# time counts events
1.000109853 2,388,560,546 cycles
2.000262846 2,393,332,358 cycles
3.000354131 2,393,176,537 cycles
4.000439503 2,393,203,790 cycles
5.000527075 2,393,167,675 cycles
6.000609052 2,393,203,670 cycles
7.000691082 2,393,175,678 cycles
The output format makes it easy to feed into a plotting program such as
gnuplot when the -I option is used in combination with the -x option:
$ perf stat -x, -I 1000 -e cycles noploop 10
noploop for 10 seconds
1.000084113,2378775498,cycles
2.000245798,2391056897,cycles
3.000354445,2392089414,cycles
4.000459115,2390936603,cycles
5.000565341,2392108173,cycles
Signed-off-by: Stephane Eranian <eranian@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1359460064-3060-3-git-send-email-eranian@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2013-01-29 19:47:44 +08:00
|
|
|
example: perf stat -I 1000 -e cycles -a sleep 5
|
2011-09-08 07:14:00 +08:00
|
|
|
|
2013-02-14 20:57:28 +08:00
|
|
|
--per-socket::
|
2013-02-06 22:46:02 +08:00
|
|
|
Aggregate counts per processor socket for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between sockets. To enable this mode,
|
2013-02-14 20:57:28 +08:00
|
|
|
use --per-socket in addition to -a. (system-wide). The output includes the
|
2013-02-06 22:46:02 +08:00
|
|
|
socket number and the number of online processors on that socket. This is
|
|
|
|
useful to gauge the amount of aggregation.
|
|
|
|
|
2013-02-14 20:57:29 +08:00
|
|
|
--per-core::
|
|
|
|
Aggregate counts per physical processor for system-wide mode measurements. This
|
|
|
|
is a useful mode to detect imbalance between physical cores. To enable this mode,
|
|
|
|
use --per-core in addition to -a. (system-wide). The output includes the
|
|
|
|
core number and the number of online logical processors on that physical processor.
|
|
|
|
|
2013-08-03 08:41:11 +08:00
|
|
|
-D msecs::
|
|
|
|
--initial-delay msecs::
|
|
|
|
After starting the program, wait msecs before measuring. This is useful to
|
|
|
|
filter out the startup phase of the program, which is often very different.
|
|
|
|
|
2009-04-20 21:52:29 +08:00
|
|
|
EXAMPLES
|
|
|
|
--------
|
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
$ perf stat -- make -j
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
Performance counter stats for 'make -j':
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
8117.370256 task clock ticks # 11.281 CPU utilization factor
|
|
|
|
678 context switches # 0.000 M/sec
|
|
|
|
133 CPU migrations # 0.000 M/sec
|
|
|
|
235724 pagefaults # 0.029 M/sec
|
|
|
|
24821162526 CPU cycles # 3057.784 M/sec
|
|
|
|
18687303457 instructions # 2302.138 M/sec
|
|
|
|
172158895 cache references # 21.209 M/sec
|
|
|
|
27075259 cache misses # 3.335 M/sec
|
2009-04-20 21:52:29 +08:00
|
|
|
|
2009-06-04 22:33:00 +08:00
|
|
|
Wall-clock time elapsed: 719.554352 msecs
|
2009-04-20 21:52:29 +08:00
|
|
|
|
|
|
|
SEE ALSO
|
|
|
|
--------
|
2009-06-06 20:56:33 +08:00
|
|
|
linkperf:perf-top[1], linkperf:perf-list[1]
|