diff options
author | Ramkumar Ramachandra <artagnon@gmail.com> | 2013-12-30 03:02:35 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-13 09:38:25 -0500 |
commit | a5846e215bd47f61133383822422c683600efa7a (patch) | |
tree | d39c8436988badf627f7f42e4c094a9f5148e133 /tools/perf | |
parent | 1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3 (diff) |
perf diff: Color the Weighted Diff column
In
$ perf diff -c wdiff:M,N
color the numbers in the Weighted Diff column using color_snprintf(),
picking the colors using get_percent_color().
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1388390555-10808-1-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-diff.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 73d8bffdd484..a77e31246c00 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -778,6 +778,7 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, | |||
778 | container_of(fmt, struct diff_hpp_fmt, fmt); | 778 | container_of(fmt, struct diff_hpp_fmt, fmt); |
779 | struct hist_entry *pair = get_pair_fmt(he, dfmt); | 779 | struct hist_entry *pair = get_pair_fmt(he, dfmt); |
780 | double diff; | 780 | double diff; |
781 | s64 wdiff; | ||
781 | char pfmt[20] = " "; | 782 | char pfmt[20] = " "; |
782 | 783 | ||
783 | if (!pair) | 784 | if (!pair) |
@@ -806,6 +807,18 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, | |||
806 | scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); | 807 | scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); |
807 | return value_color_snprintf(hpp->buf, hpp->size, | 808 | return value_color_snprintf(hpp->buf, hpp->size, |
808 | pfmt, diff); | 809 | pfmt, diff); |
810 | case COMPUTE_WEIGHTED_DIFF: | ||
811 | if (he->dummy) | ||
812 | goto dummy_print; | ||
813 | if (pair->diff.computed) | ||
814 | wdiff = pair->diff.wdiff; | ||
815 | else | ||
816 | wdiff = compute_wdiff(he, pair); | ||
817 | |||
818 | scnprintf(pfmt, 20, "%%14ld", dfmt->header_width); | ||
819 | return color_snprintf(hpp->buf, hpp->size, | ||
820 | get_percent_color(wdiff), | ||
821 | pfmt, wdiff); | ||
809 | default: | 822 | default: |
810 | BUG_ON(1); | 823 | BUG_ON(1); |
811 | } | 824 | } |
@@ -826,6 +839,12 @@ static int hpp__color_ratio(struct perf_hpp_fmt *fmt, | |||
826 | return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); | 839 | return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); |
827 | } | 840 | } |
828 | 841 | ||
842 | static int hpp__color_wdiff(struct perf_hpp_fmt *fmt, | ||
843 | struct perf_hpp *hpp, struct hist_entry *he) | ||
844 | { | ||
845 | return __hpp__color_compare(fmt, hpp, he, COMPUTE_WEIGHTED_DIFF); | ||
846 | } | ||
847 | |||
829 | static void | 848 | static void |
830 | hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) | 849 | hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) |
831 | { | 850 | { |
@@ -1007,6 +1026,9 @@ static void data__hpp_register(struct data__file *d, int idx) | |||
1007 | case PERF_HPP_DIFF__RATIO: | 1026 | case PERF_HPP_DIFF__RATIO: |
1008 | fmt->color = hpp__color_ratio; | 1027 | fmt->color = hpp__color_ratio; |
1009 | break; | 1028 | break; |
1029 | case PERF_HPP_DIFF__WEIGHTED_DIFF: | ||
1030 | fmt->color = hpp__color_wdiff; | ||
1031 | break; | ||
1010 | default: | 1032 | default: |
1011 | break; | 1033 | break; |
1012 | } | 1034 | } |