perf: add csv-style output to perf stat (v2)
PATCH 1/1 perf: add csv-style output to perf stat (v2)
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.
---
tools/perf/Documentation/perf-stat.txt +5 -0
@@ -58,6 +58,11 @@ to activate system-wide monitoring. Default is to count on all CPUs. Do not aggregate counts across all monitored CPUs in system-wide mode (-a). This option is only valid in system-wide mode. +-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. + EXAMPLES --------
tools/perf/builtin-stat.c +88 -38
211 lines not on this page · raw message
Em Wed, Dec 01, 2010 at 06:49:05PM +0200, Stephane Eranian escreveu:
Quoted 6 lines
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:
Quoted 11 lines
$ 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
[root@mica ~]# perf stat -x, -a -A -- sleep 1
-B option not supported with -x
usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list
available events
-i, --no-inherit child tasks do not inherit counters
-p, --pid <n> stat events on existing process id
Guess we'll have to disable big_num automatically when -x is specified, but at the same time notice if the user _explicitely_ asked for -B.
I'll fix this now.
- Arnaldo
Em Wed, Dec 01, 2010 at 04:10:01PM -0200, Arnaldo Carvalho de Melo escreveu:
Quoted 9 lines
Em Wed, Dec 01, 2010 at 06:49:05PM +0200, Stephane Eranian escreveu:
Quoted 4 lines
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.
[root@mica ~]# perf stat -x, -a -A -- sleep 1
-B option not supported with -x
Quoted 8 lines
usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list
Guess we'll have to disable
big_numautomatically when -x is specified, but at the same time notice if the user _explicitely_ asked for -B.I'll fix this now.
Should be OK now, patch attached. Please check if it works as expected and then I'll push it to Ingo, thanks.
[root@mica ~]# perf stat -x, -a -A -- sleep 1 2>&1 | head -5 CPU0,998.225789,task-clock-msecs CPU1,998.385393,task-clock-msecs CPU2,998.370913,task-clock-msecs CPU3,998.356865,task-clock-msecs CPU0,2272,context-switches
[root@mica ~]# perf stat -B -x, -a -A -- sleep 1 2>&1 | head -5 -B option not supported with -x
usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
[root@mica ~]# perf stat -B -a -- sleep 1 2>&1 | head -10
Performance counter stats for 'sleep 1':
3992.488962 task-clock-msecs # 3.988 CPUs
9,082 context-switches # 0.002 M/sec
15 CPU-migrations # 0.000 M/sec
160 page-faults # 0.000 M/sec
84,802,643 cycles # 21.241 M/sec (scaled from 70.03%)
45,056,634 instructions # 0.531 IPC (scaled from 80.02%)
8,672,889 branches # 2.172 M/sec (scaled from 80.01%)[root@mica ~]# perf stat -B -A -a -- sleep 1 2>&1 | head -10
Performance counter stats for 'sleep 1':
CPU0 998.135082 task-clock-msecs # 0.997 CPUs CPU1 998.137405 task-clock-msecs # 0.997 CPUs CPU2 998.144046 task-clock-msecs # 0.997 CPUs CPU3 998.146202 task-clock-msecs # 0.997 CPUs CPU0 2,280 context-switches # 0.002 M/sec CPU1 2,282 context-switches # 0.002 M/sec CPU2 2,244 context-switches # 0.002 M/sec
[root@mica ~]# perf stat --no-big-num -A -a -- sleep 1 2>&1 | head -10
Performance counter stats for 'sleep 1':
CPU0 998.125848 task-clock-msecs # 0.997 CPUs CPU1 998.244633 task-clock-msecs # 0.997 CPUs CPU2 998.337969 task-clock-msecs # 0.997 CPUs CPU3 998.313756 task-clock-msecs # 0.997 CPUs CPU0 2268 context-switches # 0.002 M/sec CPU1 2218 context-switches # 0.002 M/sec CPU2 2218 context-switches # 0.002 M/sec
[root@mica ~]#
Quoted 1 line
From
d7470b6afca85ed4388fff57fc9d89f5a3be02ffMon Sep 17 00:00:00 2001
From: Stephane Eranian <[email protected]>
Date: Wed, 1 Dec 2010 18:49:05 +0200
Subject: [PATCH] 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 <[email protected]>
Cc: Frederik Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Cc: Peter Zijlstra <[email protected]>
Cc: Robert Richter <[email protected]>
LKML-Reference: <[email protected]>
--- tools/perf/Documentation/perf-stat.txt | 5 + tools/perf/builtin-stat.c | 144 +++++++++++++++++++++++--------- 2 files changed, 109 insertions(+), 40 deletions(-)
tools/perf/Documentation/perf-stat.txt +5 -0
@@ -78,6 +78,11 @@ This option is only valid in system-wide mode. --verbose:: be more verbose (show counter open errors, etc) +-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. + EXAMPLES --------
tools/perf/builtin-stat.c +104 -40
240 lines not on this page · raw message
Signature · 1 line
1.7.1.rc2
Arnaldo,
sorry for the delay. The upstream version works for me. Thanks.
Quoted 69 lines · Arnaldo Carvalho de Melo
Em Wed, Dec 01, 2010 at 04:10:01PM -0200, Arnaldo Carvalho de Melo escreveu:
Quoted 9 lines
Em Wed, Dec 01, 2010 at 06:49:05PM +0200, Stephane Eranian escreveu:
Quoted 4 lines
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.
[root@mica ~]# perf stat -x, -a -A -- sleep 1
-B option not supported with -xQuoted 8 lines
usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list
Guess we'll have to disable
big_numautomatically when -x is specified, but at the same time notice if the user _explicitely_ asked for -B.I'll fix this now.
Should be OK now, patch attached. Please check if it works as expected and then I'll push it to Ingo, thanks.
[root@mica ~]# perf stat -x, -a -A -- sleep 1 2>&1 | head -5 CPU0,998.225789,task-clock-msecs CPU1,998.385393,task-clock-msecs CPU2,998.370913,task-clock-msecs CPU3,998.356865,task-clock-msecs CPU0,2272,context-switches
[root@mica ~]# perf stat -B -x, -a -A -- sleep 1 2>&1 | head -5 -B option not supported with -xusage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events [root@mica ~]# perf stat -B -a -- sleep 1 2>&1 | head -10
Performance counter stats for 'sleep 1':
3992.488962 task-clock-msecs # 3.988 CPUs
9,082 context-switches # 0.002 M/sec
15 CPU-migrations # 0.000 M/sec
160 page-faults # 0.000 M/sec 84,802,643 cycles # 21.241 M/sec (scaled from 70.03%) 45,056,634 instructions # 0.531 IPC (scaled from 80.02%) 8,672,889 branches # 2.172 M/sec (scaled from 80.01%) [root@mica ~]# perf stat -B -A -a -- sleep 1 2>&1 | head -10Performance counter stats for 'sleep 1':
CPU0 998.135082 task-clock-msecs # 0.997 CPUs CPU1 998.137405 task-clock-msecs # 0.997 CPUs CPU2 998.144046 task-clock-msecs # 0.997 CPUs CPU3 998.146202 task-clock-msecs # 0.997 CPUs CPU0 2,280 context-switches # 0.002 M/sec CPU1 2,282 context-switches # 0.002 M/sec CPU2 2,244 context-switches # 0.002 M/sec [root@mica ~]# perf stat --no-big-num -A -a -- sleep 1 2>&1 | head -10
Performance counter stats for 'sleep 1':
CPU0 998.125848 task-clock-msecs # 0.997 CPUs CPU1 998.244633 task-clock-msecs # 0.997 CPUs CPU2 998.337969 task-clock-msecs # 0.997 CPUs CPU3 998.313756 task-clock-msecs # 0.997 CPUs CPU0 2268 context-switches # 0.002 M/sec CPU1 2218 context-switches # 0.002 M/sec CPU2 2218 context-switches # 0.002 M/sec [root@mica ~]#
Em Fri, Dec 03, 2010 at 05:46:33PM +0100, Stephane Eranian escreveu:
Quoted 3 lines
Arnaldo,
sorry for the delay.
np
Quoted 1 line
The upstream version works for me.
Thanks for confirming!
Quoted 1 line
Thanks.
Best Regards,
- Arnaldo
[tip:perf/core] perf stat: Add csv-style output
In reply to Stephane EranianCommit-ID: d7470b6afca85ed4388fff57fc9d89f5a3be02ff Gitweb: http://git.kernel.org/tip/d7470b6afca85ed4388fff57fc9d89f5a3be02ff Author: Stephane Eranian <[email protected]> AuthorDate: Wed, 1 Dec 2010 18:49:05 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Wed, 1 Dec 2010 19:47:41 -0200
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 <[email protected]>
Cc: Frederik Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: [email protected]
Cc: Peter Zijlstra <[email protected]>
Cc: Robert Richter <[email protected]>
LKML-Reference: <[email protected]>
--- tools/perf/Documentation/perf-stat.txt | 5 + tools/perf/builtin-stat.c | 144 +++++++++++++++++++++++--------- 2 files changed, 109 insertions(+), 40 deletions(-)
tools/perf/Documentation/perf-stat.txt +5 -0
@@ -78,6 +78,11 @@ This option is only valid in system-wide mode. --verbose:: be more verbose (show counter open errors, etc) +-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. + EXAMPLES --------
tools/perf/builtin-stat.c +104 -40
240 lines not on this page · raw message