diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-02-06 02:44:44 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-02-06 16:17:11 -0500 |
commit | 5fde2523bddb71d96f12b6ee8d2a9a43cb99da96 (patch) | |
tree | 2833458233e01dc78a900b444a03f6ee58dc834c /tools | |
parent | 762b2935fc0ea2eab3a0edc8333fedb95266c7a9 (diff) |
perf stat: Adjust print unit
The default 'M/sec' unit is not useful if the result is small enough.
Adjust it dynamically according to the value.
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1328514285-26232-1-git-send-email-namhyung.kim@lge.com
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-stat.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 459b8620a5d..32d930eb754 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -844,12 +844,18 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg) | |||
844 | 844 | ||
845 | fprintf(output, " # %8.3f GHz ", ratio); | 845 | fprintf(output, " # %8.3f GHz ", ratio); |
846 | } else if (runtime_nsecs_stats[cpu].n != 0) { | 846 | } else if (runtime_nsecs_stats[cpu].n != 0) { |
847 | char unit = 'M'; | ||
848 | |||
847 | total = avg_stats(&runtime_nsecs_stats[cpu]); | 849 | total = avg_stats(&runtime_nsecs_stats[cpu]); |
848 | 850 | ||
849 | if (total) | 851 | if (total) |
850 | ratio = 1000.0 * avg / total; | 852 | ratio = 1000.0 * avg / total; |
853 | if (ratio < 0.001) { | ||
854 | ratio *= 1000; | ||
855 | unit = 'K'; | ||
856 | } | ||
851 | 857 | ||
852 | fprintf(output, " # %8.3f M/sec ", ratio); | 858 | fprintf(output, " # %8.3f %c/sec ", ratio, unit); |
853 | } else { | 859 | } else { |
854 | fprintf(output, " "); | 860 | fprintf(output, " "); |
855 | } | 861 | } |