diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-04 15:06:26 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-05 20:03:56 -0400 |
commit | b535d523dce58e8e94f7dbf741f1e9b5479e61d4 (patch) | |
tree | 6f2378e2bd169705b577e5466d5174e7e452d0d9 | |
parent | 96c144512263906cc41a25524fa114c90acd3a01 (diff) |
perf trace: Sort syscalls stats by msecs in --summary
# trace -a -s sleep 1
<SNIP>
Xorg (1965), 788 events, 19.0%, 0.000 msec
syscall calls total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- --------- --------- --------- --------- ------
select 89 731.038 0.000 8.214 175.218 36.71%
ioctl 22 0.661 0.010 0.030 0.072 10.43%
writev 42 0.253 0.002 0.006 0.011 5.94%
recvmsg 60 0.185 0.001 0.003 0.009 5.90%
setitimer 60 0.127 0.001 0.002 0.006 6.14%
read 52 0.102 0.001 0.002 0.005 8.55%
rt_sigprocmask 45 0.092 0.001 0.002 0.023 23.65%
poll 12 0.021 0.001 0.002 0.003 7.21%
epoll_wait 12 0.019 0.001 0.002 0.002 2.71%
firefox (10871), 1080 events, 26.1%, 0.000 msec
syscall calls total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- --------- --------- --------- --------- ------
poll 240 979.562 0.000 4.082 17.132 11.33%
recvmsg 240 0.532 0.001 0.002 0.007 3.69%
read 60 0.303 0.003 0.005 0.029 8.50%
Suggested-by: Milian Wolff <milian.wolff@kdab.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-52kdkuyxihq0kvc0n2aalhay@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index aac0074cc926..c61e61240b3b 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -2785,15 +2785,29 @@ static size_t trace__fprintf_threads_header(FILE *fp) | |||
2785 | return printed; | 2785 | return printed; |
2786 | } | 2786 | } |
2787 | 2787 | ||
2788 | DEFINE_RESORT_RB(syscall_stats, a->msecs > b->msecs, | ||
2789 | struct stats *stats; | ||
2790 | double msecs; | ||
2791 | int syscall; | ||
2792 | ) | ||
2793 | { | ||
2794 | struct int_node *source = rb_entry(nd, struct int_node, rb_node); | ||
2795 | struct stats *stats = source->priv; | ||
2796 | |||
2797 | entry->syscall = source->i; | ||
2798 | entry->stats = stats; | ||
2799 | entry->msecs = stats ? (u64)stats->n * (avg_stats(stats) / NSEC_PER_MSEC) : 0; | ||
2800 | } | ||
2801 | |||
2788 | static size_t thread__dump_stats(struct thread_trace *ttrace, | 2802 | static size_t thread__dump_stats(struct thread_trace *ttrace, |
2789 | struct trace *trace, FILE *fp) | 2803 | struct trace *trace, FILE *fp) |
2790 | { | 2804 | { |
2791 | struct stats *stats; | ||
2792 | size_t printed = 0; | 2805 | size_t printed = 0; |
2793 | struct syscall *sc; | 2806 | struct syscall *sc; |
2794 | struct int_node *inode = intlist__first(ttrace->syscall_stats); | 2807 | struct rb_node *nd; |
2808 | DECLARE_RESORT_RB_INTLIST(syscall_stats, ttrace->syscall_stats); | ||
2795 | 2809 | ||
2796 | if (inode == NULL) | 2810 | if (syscall_stats == NULL) |
2797 | return 0; | 2811 | return 0; |
2798 | 2812 | ||
2799 | printed += fprintf(fp, "\n"); | 2813 | printed += fprintf(fp, "\n"); |
@@ -2802,9 +2816,8 @@ static size_t thread__dump_stats(struct thread_trace *ttrace, | |||
2802 | printed += fprintf(fp, " (msec) (msec) (msec) (msec) (%%)\n"); | 2816 | printed += fprintf(fp, " (msec) (msec) (msec) (msec) (%%)\n"); |
2803 | printed += fprintf(fp, " --------------- -------- --------- --------- --------- --------- ------\n"); | 2817 | printed += fprintf(fp, " --------------- -------- --------- --------- --------- --------- ------\n"); |
2804 | 2818 | ||
2805 | /* each int_node is a syscall */ | 2819 | resort_rb__for_each(nd, syscall_stats) { |
2806 | while (inode) { | 2820 | struct stats *stats = syscall_stats_entry->stats; |
2807 | stats = inode->priv; | ||
2808 | if (stats) { | 2821 | if (stats) { |
2809 | double min = (double)(stats->min) / NSEC_PER_MSEC; | 2822 | double min = (double)(stats->min) / NSEC_PER_MSEC; |
2810 | double max = (double)(stats->max) / NSEC_PER_MSEC; | 2823 | double max = (double)(stats->max) / NSEC_PER_MSEC; |
@@ -2815,16 +2828,15 @@ static size_t thread__dump_stats(struct thread_trace *ttrace, | |||
2815 | pct = avg ? 100.0 * stddev_stats(stats)/avg : 0.0; | 2828 | pct = avg ? 100.0 * stddev_stats(stats)/avg : 0.0; |
2816 | avg /= NSEC_PER_MSEC; | 2829 | avg /= NSEC_PER_MSEC; |
2817 | 2830 | ||
2818 | sc = &trace->syscalls.table[inode->i]; | 2831 | sc = &trace->syscalls.table[syscall_stats_entry->syscall]; |
2819 | printed += fprintf(fp, " %-15s", sc->name); | 2832 | printed += fprintf(fp, " %-15s", sc->name); |
2820 | printed += fprintf(fp, " %8" PRIu64 " %9.3f %9.3f %9.3f", | 2833 | printed += fprintf(fp, " %8" PRIu64 " %9.3f %9.3f %9.3f", |
2821 | n, avg * n, min, avg); | 2834 | n, syscall_stats_entry->msecs, min, avg); |
2822 | printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct); | 2835 | printed += fprintf(fp, " %9.3f %9.2f%%\n", max, pct); |
2823 | } | 2836 | } |
2824 | |||
2825 | inode = intlist__next(inode); | ||
2826 | } | 2837 | } |
2827 | 2838 | ||
2839 | resort_rb__delete(syscall_stats); | ||
2828 | printed += fprintf(fp, "\n\n"); | 2840 | printed += fprintf(fp, "\n\n"); |
2829 | 2841 | ||
2830 | return printed; | 2842 | return printed; |