perf-stat.txt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. perf-stat(1)
  2. ============
  3. NAME
  4. ----
  5. perf-stat - Run a command and gather performance counter statistics
  6. SYNOPSIS
  7. --------
  8. [verse]
  9. 'perf stat' [-e <EVENT> | --event=EVENT] [-a] <command>
  10. 'perf stat' [-e <EVENT> | --event=EVENT] [-a] -- <command> [<options>]
  11. 'perf stat' [-e <EVENT> | --event=EVENT] [-a] record [-o file] -- <command> [<options>]
  12. 'perf stat' report [-i file]
  13. DESCRIPTION
  14. -----------
  15. This command runs a command and gathers performance counter statistics
  16. from it.
  17. OPTIONS
  18. -------
  19. <command>...::
  20. Any command you can specify in a shell.
  21. record::
  22. See STAT RECORD.
  23. report::
  24. See STAT REPORT.
  25. -e::
  26. --event=::
  27. Select the PMU event. Selection can be:
  28. - a symbolic event name (use 'perf list' to list all events)
  29. - a raw PMU event (eventsel+umask) in the form of rNNN where NNN is a
  30. hexadecimal event descriptor.
  31. - a symbolically formed event like 'pmu/param1=0x3,param2/' where
  32. param1 and param2 are defined as formats for the PMU in
  33. /sys/bus/event_sources/devices/<pmu>/format/*
  34. - a symbolically formed event like 'pmu/config=M,config1=N,config2=K/'
  35. where M, N, K are numbers (in decimal, hex, octal format).
  36. Acceptable values for each of 'config', 'config1' and 'config2'
  37. parameters are defined by corresponding entries in
  38. /sys/bus/event_sources/devices/<pmu>/format/*
  39. -i::
  40. --no-inherit::
  41. child tasks do not inherit counters
  42. -p::
  43. --pid=<pid>::
  44. stat events on existing process id (comma separated list)
  45. -t::
  46. --tid=<tid>::
  47. stat events on existing thread id (comma separated list)
  48. -a::
  49. --all-cpus::
  50. system-wide collection from all CPUs
  51. -c::
  52. --scale::
  53. scale/normalize counter values
  54. -d::
  55. --detailed::
  56. print more detailed statistics, can be specified up to 3 times
  57. -d: detailed events, L1 and LLC data cache
  58. -d -d: more detailed events, dTLB and iTLB events
  59. -d -d -d: very detailed events, adding prefetch events
  60. -r::
  61. --repeat=<n>::
  62. repeat command and print average + stddev (max: 100). 0 means forever.
  63. -B::
  64. --big-num::
  65. print large numbers with thousands' separators according to locale
  66. -C::
  67. --cpu=::
  68. Count only on the list of CPUs provided. Multiple CPUs can be provided as a
  69. comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2.
  70. In per-thread mode, this option is ignored. The -a option is still necessary
  71. to activate system-wide monitoring. Default is to count on all CPUs.
  72. -A::
  73. --no-aggr::
  74. Do not aggregate counts across all monitored CPUs in system-wide mode (-a).
  75. This option is only valid in system-wide mode.
  76. -n::
  77. --null::
  78. null run - don't start any counters
  79. -v::
  80. --verbose::
  81. be more verbose (show counter open errors, etc)
  82. -x SEP::
  83. --field-separator SEP::
  84. print counts using a CSV-style output to make it easy to import directly into
  85. spreadsheets. Columns are separated by the string specified in SEP.
  86. -G name::
  87. --cgroup name::
  88. monitor only in the container (cgroup) called "name". This option is available only
  89. in per-cpu mode. The cgroup filesystem must be mounted. All threads belonging to
  90. container "name" are monitored when they run on the monitored CPUs. Multiple cgroups
  91. can be provided. Each cgroup is applied to the corresponding event, i.e., first cgroup
  92. to first event, second cgroup to second event and so on. It is possible to provide
  93. an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must have
  94. corresponding events, i.e., they always refer to events defined earlier on the command
  95. line.
  96. -o file::
  97. --output file::
  98. Print the output into the designated file.
  99. --append::
  100. Append to the output file designated with the -o option. Ignored if -o is not specified.
  101. --log-fd::
  102. Log output to fd, instead of stderr. Complementary to --output, and mutually exclusive
  103. with it. --append may be used here. Examples:
  104. 3>results perf stat --log-fd 3 -- $cmd
  105. 3>>results perf stat --log-fd 3 --append -- $cmd
  106. --pre::
  107. --post::
  108. Pre and post measurement hooks, e.g.:
  109. perf stat --repeat 10 --null --sync --pre 'make -s O=defconfig-build/clean' -- make -s -j64 O=defconfig-build/ bzImage
  110. -I msecs::
  111. --interval-print msecs::
  112. Print count deltas every N milliseconds (minimum: 10ms)
  113. The overhead percentage could be high in some cases, for instance with small, sub 100ms intervals. Use with caution.
  114. example: 'perf stat -I 1000 -e cycles -a sleep 5'
  115. --metric-only::
  116. Only print computed metrics. Print them in a single line.
  117. Don't show any raw values. Not supported with --per-thread.
  118. --per-socket::
  119. Aggregate counts per processor socket for system-wide mode measurements. This
  120. is a useful mode to detect imbalance between sockets. To enable this mode,
  121. use --per-socket in addition to -a. (system-wide). The output includes the
  122. socket number and the number of online processors on that socket. This is
  123. useful to gauge the amount of aggregation.
  124. --per-core::
  125. Aggregate counts per physical processor for system-wide mode measurements. This
  126. is a useful mode to detect imbalance between physical cores. To enable this mode,
  127. use --per-core in addition to -a. (system-wide). The output includes the
  128. core number and the number of online logical processors on that physical processor.
  129. --per-thread::
  130. Aggregate counts per monitored threads, when monitoring threads (-t option)
  131. or processes (-p option).
  132. -D msecs::
  133. --delay msecs::
  134. After starting the program, wait msecs before measuring. This is useful to
  135. filter out the startup phase of the program, which is often very different.
  136. -T::
  137. --transaction::
  138. Print statistics of transactional execution if supported.
  139. STAT RECORD
  140. -----------
  141. Stores stat data into perf data file.
  142. -o file::
  143. --output file::
  144. Output file name.
  145. STAT REPORT
  146. -----------
  147. Reads and reports stat data from perf data file.
  148. -i file::
  149. --input file::
  150. Input file name.
  151. --per-socket::
  152. Aggregate counts per processor socket for system-wide mode measurements.
  153. --per-core::
  154. Aggregate counts per physical processor for system-wide mode measurements.
  155. -A::
  156. --no-aggr::
  157. Do not aggregate counts across all monitored CPUs.
  158. EXAMPLES
  159. --------
  160. $ perf stat -- make -j
  161. Performance counter stats for 'make -j':
  162. 8117.370256 task clock ticks # 11.281 CPU utilization factor
  163. 678 context switches # 0.000 M/sec
  164. 133 CPU migrations # 0.000 M/sec
  165. 235724 pagefaults # 0.029 M/sec
  166. 24821162526 CPU cycles # 3057.784 M/sec
  167. 18687303457 instructions # 2302.138 M/sec
  168. 172158895 cache references # 21.209 M/sec
  169. 27075259 cache misses # 3.335 M/sec
  170. Wall-clock time elapsed: 719.554352 msecs
  171. CSV FORMAT
  172. ----------
  173. With -x, perf stat is able to output a not-quite-CSV format output
  174. Commas in the output are not put into "". To make it easy to parse
  175. it is recommended to use a different character like -x \;
  176. The fields are in this order:
  177. - optional usec time stamp in fractions of second (with -I xxx)
  178. - optional CPU, core, or socket identifier
  179. - optional number of logical CPUs aggregated
  180. - counter value
  181. - unit of the counter value or empty
  182. - event name
  183. - run time of counter
  184. - percentage of measurement time the counter was running
  185. - optional variance if multiple values are collected with -r
  186. - optional metric value
  187. - optional unit of metric
  188. Additional metrics may be printed with all earlier fields being empty.
  189. SEE ALSO
  190. --------
  191. linkperf:perf-top[1], linkperf:perf-list[1]