* [PATCH v6 0/4] More color in 'perf diff'
@ 2013-12-30 7:34 Ramkumar Ramachandra
2013-12-30 7:34 ` [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() Ramkumar Ramachandra
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Ramkumar Ramachandra @ 2013-12-30 7:34 UTC (permalink / raw)
To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo
The differences in this series are:
- [1/4] and [2/4] have been split out.
- [4/4] uses value_color_snprintf() instead of green/ red for positive/
negative values.
Thanks.
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Ramkumar Ramachandra (4):
perf tools: generalize percent_color_snprintf()
perf diff: color the Delta column
perf diff: color the Ratio column
perf diff: color the Weighted Diff column
tools/perf/builtin-diff.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++-
tools/perf/util/color.c | 15 +++++---
tools/perf/util/color.h | 1 +
3 files changed, 100 insertions(+), 6 deletions(-)
--
1.8.5.2.227.g53f3478
^ permalink raw reply [flat|nested] 13+ messages in thread* [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra @ 2013-12-30 7:34 ` Ramkumar Ramachandra 2014-01-14 16:41 ` [tip:perf/core] perf tools: Generalize percent_color_snprintf() tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 2/4] perf diff: color the Delta column Ramkumar Ramachandra ` (3 subsequent siblings) 4 siblings, 1 reply; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 7:34 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo Make percent_color_snprintf() handle negative values correctly. Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- tools/perf/util/color.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 66e44a5..8cda46c 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -1,6 +1,7 @@ #include <linux/kernel.h> #include "cache.h" #include "color.h" +#include <math.h> int perf_use_color_default = -1; @@ -298,10 +299,10 @@ const char *get_percent_color(double percent) * entries in green - and keep the low overhead places * normal: */ - if (percent >= MIN_RED) + if (fabs(percent) >= MIN_RED) color = PERF_COLOR_RED; else { - if (percent > MIN_GREEN) + if (fabs(percent) > MIN_GREEN) color = PERF_COLOR_GREEN; } return color; -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf tools: Generalize percent_color_snprintf() 2013-12-30 7:34 ` [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() Ramkumar Ramachandra @ 2014-01-14 16:41 ` tip-bot for Ramkumar Ramachandra 0 siblings, 0 replies; 13+ messages in thread From: tip-bot for Ramkumar Ramachandra @ 2014-01-14 16:41 UTC (permalink / raw) To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, artagnon, tglx, jolsa Commit-ID: f77c6e9c8f9c444cd44423df0c2708e86a06a696 Gitweb: http://git.kernel.org/tip/f77c6e9c8f9c444cd44423df0c2708e86a06a696 Author: Ramkumar Ramachandra <artagnon@gmail.com> AuthorDate: Mon, 30 Dec 2013 13:04:18 +0530 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 13 Jan 2014 10:46:39 -0300 perf tools: Generalize percent_color_snprintf() Make percent_color_snprintf() handle negative values correctly. 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-2-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/util/color.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 66e44a5..8cda46c 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -1,6 +1,7 @@ #include <linux/kernel.h> #include "cache.h" #include "color.h" +#include <math.h> int perf_use_color_default = -1; @@ -298,10 +299,10 @@ const char *get_percent_color(double percent) * entries in green - and keep the low overhead places * normal: */ - if (percent >= MIN_RED) + if (fabs(percent) >= MIN_RED) color = PERF_COLOR_RED; else { - if (percent > MIN_GREEN) + if (fabs(percent) > MIN_GREEN) color = PERF_COLOR_GREEN; } return color; ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 2/4] perf diff: color the Delta column 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() Ramkumar Ramachandra @ 2013-12-30 7:34 ` Ramkumar Ramachandra 2014-01-14 16:41 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 3/4] perf diff: color the Ratio column Ramkumar Ramachandra ` (2 subsequent siblings) 4 siblings, 1 reply; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 7:34 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo Color the numbers in the Delta column using percent_color_snprintf(). Generalize the coloring function so that we can accommodate all three comparison methods in future patches: delta, ratio, and wdiff. Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- tools/perf/builtin-diff.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 3b67ea2..a8fc525 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -769,6 +769,45 @@ static int hpp__entry_baseline(struct hist_entry *he, char *buf, size_t size) return ret; } +static int __hpp__color_compare(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he, + int comparison_method) +{ + struct diff_hpp_fmt *dfmt = + container_of(fmt, struct diff_hpp_fmt, fmt); + struct hist_entry *pair = get_pair_fmt(he, dfmt); + double diff; + char pfmt[20] = " "; + + if (!pair) + goto dummy_print; + + switch (comparison_method) { + case COMPUTE_DELTA: + if (pair->diff.computed) + diff = pair->diff.period_ratio_delta; + else + diff = compute_delta(he, pair); + + if (fabs(diff) < 0.01) + goto dummy_print; + scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1); + return percent_color_snprintf(hpp->buf, hpp->size, + pfmt, diff); + default: + BUG_ON(1); + } +dummy_print: + return scnprintf(hpp->buf, hpp->size, "%*s", + dfmt->header_width, pfmt); +} + +static int hpp__color_delta(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -940,8 +979,16 @@ static void data__hpp_register(struct data__file *d, int idx) fmt->entry = hpp__entry_global; /* TODO more colors */ - if (idx == PERF_HPP_DIFF__BASELINE) + switch (idx) { + case PERF_HPP_DIFF__BASELINE: fmt->color = hpp__color_baseline; + break; + case PERF_HPP_DIFF__DELTA: + fmt->color = hpp__color_delta; + break; + default: + break; + } init_header(d, dfmt); perf_hpp__column_register(fmt); -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf diff: Color the Delta column 2013-12-30 7:34 ` [PATCH v6 2/4] perf diff: color the Delta column Ramkumar Ramachandra @ 2014-01-14 16:41 ` tip-bot for Ramkumar Ramachandra 0 siblings, 0 replies; 13+ messages in thread From: tip-bot for Ramkumar Ramachandra @ 2014-01-14 16:41 UTC (permalink / raw) To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, artagnon, tglx, jolsa Commit-ID: 01f10bc85f538cd681d0a3338b97a33f308d944b Gitweb: http://git.kernel.org/tip/01f10bc85f538cd681d0a3338b97a33f308d944b Author: Ramkumar Ramachandra <artagnon@gmail.com> AuthorDate: Mon, 30 Dec 2013 13:04:19 +0530 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 13 Jan 2014 11:36:46 -0300 perf diff: Color the Delta column Color the numbers in the Delta column using percent_color_snprintf(). Generalize the coloring function so that we can accommodate all three comparison methods in future patches: delta, ratio, and wdiff. 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-3-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/builtin-diff.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 987cac3..6c3f220 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -770,6 +770,45 @@ static int hpp__entry_baseline(struct hist_entry *he, char *buf, size_t size) return ret; } +static int __hpp__color_compare(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he, + int comparison_method) +{ + struct diff_hpp_fmt *dfmt = + container_of(fmt, struct diff_hpp_fmt, fmt); + struct hist_entry *pair = get_pair_fmt(he, dfmt); + double diff; + char pfmt[20] = " "; + + if (!pair) + goto dummy_print; + + switch (comparison_method) { + case COMPUTE_DELTA: + if (pair->diff.computed) + diff = pair->diff.period_ratio_delta; + else + diff = compute_delta(he, pair); + + if (fabs(diff) < 0.01) + goto dummy_print; + scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1); + return percent_color_snprintf(hpp->buf, hpp->size, + pfmt, diff); + default: + BUG_ON(1); + } +dummy_print: + return scnprintf(hpp->buf, hpp->size, "%*s", + dfmt->header_width, pfmt); +} + +static int hpp__color_delta(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -941,8 +980,16 @@ static void data__hpp_register(struct data__file *d, int idx) fmt->entry = hpp__entry_global; /* TODO more colors */ - if (idx == PERF_HPP_DIFF__BASELINE) + switch (idx) { + case PERF_HPP_DIFF__BASELINE: fmt->color = hpp__color_baseline; + break; + case PERF_HPP_DIFF__DELTA: + fmt->color = hpp__color_delta; + break; + default: + break; + } init_header(d, dfmt); perf_hpp__column_register(fmt); ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 3/4] perf diff: color the Ratio column 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 2/4] perf diff: color the Delta column Ramkumar Ramachandra @ 2013-12-30 7:34 ` Ramkumar Ramachandra 2014-01-14 16:42 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 4/4] perf diff: color the Weighted Diff column Ramkumar Ramachandra 2014-01-06 8:36 ` [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 4 siblings, 1 reply; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 7:34 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo 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. Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- tools/perf/builtin-diff.c | 20 ++++++++++++++++++++ tools/perf/util/color.c | 10 +++++++--- tools/perf/util/color.h | 1 + 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index a8fc525..c07cd3c 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -794,6 +794,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1); return percent_color_snprintf(hpp->buf, hpp->size, pfmt, diff); + case COMPUTE_RATIO: + if (he->dummy) + goto dummy_print; + if (pair->diff.computed) + diff = pair->diff.period_ratio; + else + diff = compute_ratio(he, pair); + + scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); + return value_color_snprintf(hpp->buf, hpp->size, + pfmt, diff); default: BUG_ON(1); } @@ -808,6 +819,12 @@ static int hpp__color_delta(struct perf_hpp_fmt *fmt, return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA); } +static int hpp__color_ratio(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -986,6 +1003,9 @@ static void data__hpp_register(struct data__file *d, int idx) case PERF_HPP_DIFF__DELTA: fmt->color = hpp__color_delta; break; + case PERF_HPP_DIFF__RATIO: + fmt->color = hpp__color_ratio; + break; default: break; } diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 8cda46c..87b8672 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -319,15 +319,19 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent) return r; } +int value_color_snprintf(char *bf, size_t size, const char *fmt, double value) +{ + const char *color = get_percent_color(value); + return color_snprintf(bf, size, color, fmt, value); +} + int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...) { va_list args; double percent; - const char *color; va_start(args, fmt); percent = va_arg(args, double); va_end(args); - color = get_percent_color(percent); - return color_snprintf(bf, size, color, fmt, percent); + return value_color_snprintf(bf, size, fmt, percent); } diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index fced384..7ff30a6 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -39,6 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...); int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); +int value_color_snprintf(char *bf, size_t size, const char *fmt, double value); int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...); int percent_color_fprintf(FILE *fp, const char *fmt, double percent); const char *get_percent_color(double percent); -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf diff: Color the Ratio column 2013-12-30 7:34 ` [PATCH v6 3/4] perf diff: color the Ratio column Ramkumar Ramachandra @ 2014-01-14 16:42 ` tip-bot for Ramkumar Ramachandra 0 siblings, 0 replies; 13+ messages in thread From: tip-bot for Ramkumar Ramachandra @ 2014-01-14 16:42 UTC (permalink / raw) To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, artagnon, tglx, jolsa Commit-ID: 1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3 Gitweb: http://git.kernel.org/tip/1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3 Author: Ramkumar Ramachandra <artagnon@gmail.com> AuthorDate: Mon, 30 Dec 2013 13:04:20 +0530 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 13 Jan 2014 11:37:17 -0300 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> --- tools/perf/builtin-diff.c | 20 ++++++++++++++++++++ tools/perf/util/color.c | 10 +++++++--- tools/perf/util/color.h | 1 + 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 6c3f220..73d8bff 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, scnprintf(pfmt, 20, "%%%+d.2f%%%%", dfmt->header_width - 1); return percent_color_snprintf(hpp->buf, hpp->size, pfmt, diff); + case COMPUTE_RATIO: + if (he->dummy) + goto dummy_print; + if (pair->diff.computed) + diff = pair->diff.period_ratio; + else + diff = compute_ratio(he, pair); + + scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); + return value_color_snprintf(hpp->buf, hpp->size, + pfmt, diff); default: BUG_ON(1); } @@ -809,6 +820,12 @@ static int hpp__color_delta(struct perf_hpp_fmt *fmt, return __hpp__color_compare(fmt, hpp, he, COMPUTE_DELTA); } +static int hpp__color_ratio(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -987,6 +1004,9 @@ static void data__hpp_register(struct data__file *d, int idx) case PERF_HPP_DIFF__DELTA: fmt->color = hpp__color_delta; break; + case PERF_HPP_DIFF__RATIO: + fmt->color = hpp__color_ratio; + break; default: break; } diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c index 8cda46c..87b8672 100644 --- a/tools/perf/util/color.c +++ b/tools/perf/util/color.c @@ -319,15 +319,19 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent) return r; } +int value_color_snprintf(char *bf, size_t size, const char *fmt, double value) +{ + const char *color = get_percent_color(value); + return color_snprintf(bf, size, color, fmt, value); +} + int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...) { va_list args; double percent; - const char *color; va_start(args, fmt); percent = va_arg(args, double); va_end(args); - color = get_percent_color(percent); - return color_snprintf(bf, size, color, fmt, percent); + return value_color_snprintf(bf, size, fmt, percent); } diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h index fced384..7ff30a6 100644 --- a/tools/perf/util/color.h +++ b/tools/perf/util/color.h @@ -39,6 +39,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...); int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...); int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...); int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf); +int value_color_snprintf(char *bf, size_t size, const char *fmt, double value); int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...); int percent_color_fprintf(FILE *fp, const char *fmt, double percent); const char *get_percent_color(double percent); ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 4/4] perf diff: color the Weighted Diff column 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra ` (2 preceding siblings ...) 2013-12-30 7:34 ` [PATCH v6 3/4] perf diff: color the Ratio column Ramkumar Ramachandra @ 2013-12-30 7:34 ` Ramkumar Ramachandra 2013-12-30 7:48 ` Ramkumar Ramachandra 2013-12-30 8:02 ` [PATCH v7] " Ramkumar Ramachandra 2014-01-06 8:36 ` [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 4 siblings, 2 replies; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 7:34 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo In $ perf diff -c wdiff:M,N color the numbers in the Weighted Diff column using value_color_snprintf(). Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- tools/perf/builtin-diff.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index c07cd3c..9c69620 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -777,6 +777,7 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, container_of(fmt, struct diff_hpp_fmt, fmt); struct hist_entry *pair = get_pair_fmt(he, dfmt); double diff; + s64 wdiff; char pfmt[20] = " "; if (!pair) @@ -805,6 +806,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); return value_color_snprintf(hpp->buf, hpp->size, pfmt, diff); + case COMPUTE_WEIGHTED_DIFF: + if (he->dummy) + goto dummy_print; + if (pair->diff.computed) + wdiff = pair->diff.wdiff; + else + wdiff = compute_wdiff(he, pair); + + scnprintf(pfmt, 20, "%%14ld", dfmt->header_width); + return value_color_snprintf(hpp->buf, hpp->size, + pfmt, wdiff); default: BUG_ON(1); } @@ -825,6 +837,12 @@ static int hpp__color_ratio(struct perf_hpp_fmt *fmt, return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); } +static int hpp__color_wdiff(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_WEIGHTED_DIFF); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -1006,6 +1024,9 @@ static void data__hpp_register(struct data__file *d, int idx) case PERF_HPP_DIFF__RATIO: fmt->color = hpp__color_ratio; break; + case PERF_HPP_DIFF__WEIGHTED_DIFF: + fmt->color = hpp__color_wdiff; + break; default: break; } -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v6 4/4] perf diff: color the Weighted Diff column 2013-12-30 7:34 ` [PATCH v6 4/4] perf diff: color the Weighted Diff column Ramkumar Ramachandra @ 2013-12-30 7:48 ` Ramkumar Ramachandra 2013-12-30 8:02 ` [PATCH v7] " Ramkumar Ramachandra 1 sibling, 0 replies; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 7:48 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo Ramkumar Ramachandra wrote: > diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c > index c07cd3c..9c69620 100644 > --- a/tools/perf/builtin-diff.c > +++ b/tools/perf/builtin-diff.c > @@ -777,6 +777,7 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, > container_of(fmt, struct diff_hpp_fmt, fmt); > struct hist_entry *pair = get_pair_fmt(he, dfmt); > double diff; > + s64 wdiff; > char pfmt[20] = " "; > > if (!pair) > @@ -805,6 +806,17 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, > scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); > return value_color_snprintf(hpp->buf, hpp->size, > pfmt, diff); > + case COMPUTE_WEIGHTED_DIFF: > + if (he->dummy) > + goto dummy_print; > + if (pair->diff.computed) > + wdiff = pair->diff.wdiff; > + else > + wdiff = compute_wdiff(he, pair); > + > + scnprintf(pfmt, 20, "%%14ld", dfmt->header_width); > + return value_color_snprintf(hpp->buf, hpp->size, > + pfmt, wdiff); Oops, I sent this out too fast. value_color_snprintf() accepts a double, but wdiff is an s64. As a result, the wdiff column is populated with zeros. Will resend. ^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v7] perf diff: color the Weighted Diff column 2013-12-30 7:34 ` [PATCH v6 4/4] perf diff: color the Weighted Diff column Ramkumar Ramachandra 2013-12-30 7:48 ` Ramkumar Ramachandra @ 2013-12-30 8:02 ` Ramkumar Ramachandra 2014-01-14 16:42 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 1 sibling, 1 reply; 13+ messages in thread From: Ramkumar Ramachandra @ 2013-12-30 8:02 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo 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(). Cc: Jiri Olsa <jolsa@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> --- In v6, I made the blunder of using value_color_snprintf(), zeroing out the numbers in the wdiff column. This iteration calls get_percent_color() by hand, making sure that the last s64 argument is not coerced into a double. tools/perf/builtin-diff.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index c07cd3c..a1a5dfb 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -777,6 +777,7 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, container_of(fmt, struct diff_hpp_fmt, fmt); struct hist_entry *pair = get_pair_fmt(he, dfmt); double diff; + s64 wdiff; char pfmt[20] = " "; if (!pair) @@ -805,6 +806,18 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); return value_color_snprintf(hpp->buf, hpp->size, pfmt, diff); + case COMPUTE_WEIGHTED_DIFF: + if (he->dummy) + goto dummy_print; + if (pair->diff.computed) + wdiff = pair->diff.wdiff; + else + wdiff = compute_wdiff(he, pair); + + scnprintf(pfmt, 20, "%%14ld", dfmt->header_width); + return color_snprintf(hpp->buf, hpp->size, + get_percent_color(wdiff), + pfmt, wdiff); default: BUG_ON(1); } @@ -825,6 +838,12 @@ static int hpp__color_ratio(struct perf_hpp_fmt *fmt, return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); } +static int hpp__color_wdiff(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_WEIGHTED_DIFF); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -1006,6 +1025,9 @@ static void data__hpp_register(struct data__file *d, int idx) case PERF_HPP_DIFF__RATIO: fmt->color = hpp__color_ratio; break; + case PERF_HPP_DIFF__WEIGHTED_DIFF: + fmt->color = hpp__color_wdiff; + break; default: break; } -- 1.8.5.2.227.g53f3478 ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [tip:perf/core] perf diff: Color the Weighted Diff column 2013-12-30 8:02 ` [PATCH v7] " Ramkumar Ramachandra @ 2014-01-14 16:42 ` tip-bot for Ramkumar Ramachandra 0 siblings, 0 replies; 13+ messages in thread From: tip-bot for Ramkumar Ramachandra @ 2014-01-14 16:42 UTC (permalink / raw) To: linux-tip-commits; +Cc: acme, linux-kernel, hpa, mingo, artagnon, tglx, jolsa Commit-ID: a5846e215bd47f61133383822422c683600efa7a Gitweb: http://git.kernel.org/tip/a5846e215bd47f61133383822422c683600efa7a Author: Ramkumar Ramachandra <artagnon@gmail.com> AuthorDate: Mon, 30 Dec 2013 13:32:35 +0530 Committer: Arnaldo Carvalho de Melo <acme@redhat.com> CommitDate: Mon, 13 Jan 2014 11:38:25 -0300 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> --- tools/perf/builtin-diff.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 73d8bff..a77e312 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, container_of(fmt, struct diff_hpp_fmt, fmt); struct hist_entry *pair = get_pair_fmt(he, dfmt); double diff; + s64 wdiff; char pfmt[20] = " "; if (!pair) @@ -806,6 +807,18 @@ static int __hpp__color_compare(struct perf_hpp_fmt *fmt, scnprintf(pfmt, 20, "%%%d.6f", dfmt->header_width); return value_color_snprintf(hpp->buf, hpp->size, pfmt, diff); + case COMPUTE_WEIGHTED_DIFF: + if (he->dummy) + goto dummy_print; + if (pair->diff.computed) + wdiff = pair->diff.wdiff; + else + wdiff = compute_wdiff(he, pair); + + scnprintf(pfmt, 20, "%%14ld", dfmt->header_width); + return color_snprintf(hpp->buf, hpp->size, + get_percent_color(wdiff), + pfmt, wdiff); default: BUG_ON(1); } @@ -826,6 +839,12 @@ static int hpp__color_ratio(struct perf_hpp_fmt *fmt, return __hpp__color_compare(fmt, hpp, he, COMPUTE_RATIO); } +static int hpp__color_wdiff(struct perf_hpp_fmt *fmt, + struct perf_hpp *hpp, struct hist_entry *he) +{ + return __hpp__color_compare(fmt, hpp, he, COMPUTE_WEIGHTED_DIFF); +} + static void hpp__entry_unpair(struct hist_entry *he, int idx, char *buf, size_t size) { @@ -1007,6 +1026,9 @@ static void data__hpp_register(struct data__file *d, int idx) case PERF_HPP_DIFF__RATIO: fmt->color = hpp__color_ratio; break; + case PERF_HPP_DIFF__WEIGHTED_DIFF: + fmt->color = hpp__color_wdiff; + break; default: break; } ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/4] More color in 'perf diff' 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra ` (3 preceding siblings ...) 2013-12-30 7:34 ` [PATCH v6 4/4] perf diff: color the Weighted Diff column Ramkumar Ramachandra @ 2014-01-06 8:36 ` Ramkumar Ramachandra 2014-01-06 14:34 ` Jiri Olsa 4 siblings, 1 reply; 13+ messages in thread From: Ramkumar Ramachandra @ 2014-01-06 8:36 UTC (permalink / raw) To: LKML; +Cc: Jiri Olsa, Arnaldo Carvalho de Melo Ramkumar Ramachandra wrote: > Ramkumar Ramachandra (4): > perf tools: generalize percent_color_snprintf() > perf diff: color the Delta column > perf diff: color the Ratio column > perf diff: color the Weighted Diff column Ping? Any progress on this Arnaldo, Jiri? ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/4] More color in 'perf diff' 2014-01-06 8:36 ` [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra @ 2014-01-06 14:34 ` Jiri Olsa 0 siblings, 0 replies; 13+ messages in thread From: Jiri Olsa @ 2014-01-06 14:34 UTC (permalink / raw) To: Ramkumar Ramachandra; +Cc: LKML, Arnaldo Carvalho de Melo On Mon, Jan 06, 2014 at 02:06:36PM +0530, Ramkumar Ramachandra wrote: > Ramkumar Ramachandra wrote: > > Ramkumar Ramachandra (4): > > perf tools: generalize percent_color_snprintf() > > perf diff: color the Delta column > > perf diff: color the Ratio column > > perf diff: color the Weighted Diff column > > > Ping? > > Any progress on this Arnaldo, Jiri? I'll get to it this week, sry for delay jirka ^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-01-14 16:44 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-12-30 7:34 [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 1/4] perf tools: generalize percent_color_snprintf() Ramkumar Ramachandra 2014-01-14 16:41 ` [tip:perf/core] perf tools: Generalize percent_color_snprintf() tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 2/4] perf diff: color the Delta column Ramkumar Ramachandra 2014-01-14 16:41 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 3/4] perf diff: color the Ratio column Ramkumar Ramachandra 2014-01-14 16:42 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 2013-12-30 7:34 ` [PATCH v6 4/4] perf diff: color the Weighted Diff column Ramkumar Ramachandra 2013-12-30 7:48 ` Ramkumar Ramachandra 2013-12-30 8:02 ` [PATCH v7] " Ramkumar Ramachandra 2014-01-14 16:42 ` [tip:perf/core] perf diff: Color " tip-bot for Ramkumar Ramachandra 2014-01-06 8:36 ` [PATCH v6 0/4] More color in 'perf diff' Ramkumar Ramachandra 2014-01-06 14:34 ` Jiri Olsa
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox