aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-diff.c
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-12-30 02:34:20 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-01-13 09:37:17 -0500
commit1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3 (patch)
treea53d0f8f29a86b8a2e2043379d06887351a07d02 /tools/perf/builtin-diff.c
parent01f10bc85f538cd681d0a3338b97a33f308d944b (diff)
perf diff: Color the Ratio column
In $ perf diff -c ratio color the Ratio column using value_color_snprintf(), a new function that operates exactly like percent_color_snprintf(). At first glance, it looks like percent_color_snprintf() can be turned into a non-variadic function simplifying things; however, 53805ec (perf tools: Remove cast of non-variadic function to variadic, 2013-10-31) explains why it needs to be a variadic function. 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/1388388861-7931-4-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-diff.c')
-rw-r--r--tools/perf/builtin-diff.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c
index 6c3f220115ac..73d8bffdd484 100644
--- a/tools/perf/builtin-diff.c
+++ b/tools/perf/builtin-diff.c
@@ -795,6 +795,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt,
795 scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1); 795 scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1);
796 return percent_color_snprintf(hpp->buf, hpp->size, 796 return percent_color_snprintf(hpp->buf, hpp->size,
797 pfmt, diff); 797 pfmt, diff);
798 case COMPUTE_RATIO:
799 if (he->dummy)
800 goto dummy_print;
801 if (pair->diff.computed)
802 diff = pair->diff.period_ratio;
803 else
804 diff = compute_ratio(he, pair);
805
806 scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width);
807 return value_color_snprintf(hpp->buf, hpp->size,
808 pfmt, diff);
798 default: 809 default:
799 BUG_ON(1); 810 BUG_ON(1);
800 } 811 }
@@ -809,6 +820,12 @@ static int hpp__color_delta(struct perf_hpp_fmt *fmt,
809 return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA); 820 return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA);
810} 821}
811 822
823static int hpp__color_ratio(struct perf_hpp_fmt *fmt,
824 struct perf_hpp *hpp, struct hist_entry *he)
825{
826 return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO);
827}
828
812static void 829static void
813hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) 830hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size)
814{ 831{
@@ -987,6 +1004,9 @@ static void data__hpp_register(struct data__file *d, int idx)
987 case PERF_HPP_DIFF__DELTA: 1004 case PERF_HPP_DIFF__DELTA:
988 fmt->color = hpp__color_delta; 1005 fmt->color = hpp__color_delta;
989 break; 1006 break;
1007 case PERF_HPP_DIFF__RATIO:
1008 fmt->color = hpp__color_ratio;
1009 break;
990 default: 1010 default:
991 break; 1011 break;
992 } 1012 }