aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/color.c
diff options
context:
space:
mode:
authorStephane Eranian <eranian@google.com>2011-08-15 22:22:33 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-08-18 07:46:13 -0300
commit4aa9015f8bfd2c8d7cc33a360275b71a9d708b37 (patch)
tree868d22562ba20ed87698e69cf33d29cce19764fb /tools/perf/util/color.c
parentperf annotate: Add --symfs option (diff)
downloadlinux-dev-4aa9015f8bfd2c8d7cc33a360275b71a9d708b37.tar.xz
linux-dev-4aa9015f8bfd2c8d7cc33a360275b71a9d708b37.zip
perf stat: Add -o and --append options
This patch adds an option (-o) to save the output of perf stat into a file. You could do this with perf record but not with perf stat. Instead, you had to fiddle with stderr to save the counts into a separate file. The patch also adds the --append option so that results can be concatenated into a single file across runs. Each run of the tool is clearly separated by a comment line starting with a hash mark. The -A option of perf record is already used by perf stat, so we only add a long option. $ perf stat -o res.txt date $ cat res.txt Performance counter stats for 'date': 0.791306 task-clock # 0.668 CPUs utilized 2 context-switches # 0.003 M/sec 0 CPU-migrations # 0.000 M/sec 197 page-faults # 0.249 M/sec 1878143 cycles # 2.373 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 1083367 instructions # 0.58 insns per cycle 193027 branches # 243.935 M/sec 9014 branch-misses # 4.67% of all branches 0.001184746 seconds time elapsed The option can be combined with -x to make the output file much easier to parse. Cc: Ingo Molnar <mingo@elte.hu> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20110815202233.GA18535@quad Signed-off-by: Stephane Eranian <eranian@google.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/color.c')
-rw-r--r--tools/perf/util/color.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index e191eb9a667f..521c38a79190 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -200,7 +200,7 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
* Auto-detect:
*/
if (perf_use_color_default < 0) {
- if (isatty(1) || pager_in_use())
+ if (isatty(fileno(fp)) || pager_in_use())
perf_use_color_default = 1;
else
perf_use_color_default = 0;