Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH v6 0/4] More color in 'perf diff'

1 view
Skip to first unread message

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:40:01 AM12/30/13
to
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 <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:40:02 AM12/30/13
to
In

$ perf diff -c wdiff:M,N

color the numbers in the Weighted Diff column using
value_color_snprintf().

Cc: Jiri Olsa <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <arta...@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;

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:40:02 AM12/30/13
to
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 <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <arta...@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);

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:40:02 AM12/30/13
to
Make percent_color_snprintf() handle negative values correctly.

Cc: Jiri Olsa <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <arta...@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;

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:40:02 AM12/30/13
to
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 <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <arta...@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);

Ramkumar Ramachandra

unread,
Dec 30, 2013, 2:50:04 AM12/30/13
to
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.

Ramkumar Ramachandra

unread,
Dec 30, 2013, 3:10:02 AM12/30/13
to
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 <jo...@redhat.com>
Cc: Arnaldo Carvalho de Melo <ac...@redhat.com>
Signed-off-by: Ramkumar Ramachandra <arta...@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)

Ramkumar Ramachandra

unread,
Jan 6, 2014, 3:40:01 AM1/6/14
to
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?

Jiri Olsa

unread,
Jan 6, 2014, 9:40:02 AM1/6/14
to
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

tip-bot for Ramkumar Ramachandra

unread,
Jan 14, 2014, 11:50:01 AM1/14/14
to
Commit-ID: 1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3
Gitweb: http://git.kernel.org/tip/1f513b2c1e8a2008b8ab767fdb6fa6c154591ed3
Author: Ramkumar Ramachandra <arta...@gmail.com>
AuthorDate: Mon, 30 Dec 2013 13:04:20 +0530
Committer: Arnaldo Carvalho de Melo <ac...@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 <arta...@gmail.com>
Acked-by: Jiri Olsa <jo...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Link: http://lkml.kernel.org/r/1388388861-7931-4-gi...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@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)

tip-bot for Ramkumar Ramachandra

unread,
Jan 14, 2014, 11:50:01 AM1/14/14
to
Commit-ID: f77c6e9c8f9c444cd44423df0c2708e86a06a696
Gitweb: http://git.kernel.org/tip/f77c6e9c8f9c444cd44423df0c2708e86a06a696
Author: Ramkumar Ramachandra <arta...@gmail.com>
AuthorDate: Mon, 30 Dec 2013 13:04:18 +0530
Committer: Arnaldo Carvalho de Melo <ac...@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 <arta...@gmail.com>
Acked-by: Jiri Olsa <jo...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Link: http://lkml.kernel.org/r/1388388861-7931-2-gi...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@redhat.com>

tip-bot for Ramkumar Ramachandra

unread,
Jan 14, 2014, 11:50:02 AM1/14/14
to
Commit-ID: a5846e215bd47f61133383822422c683600efa7a
Gitweb: http://git.kernel.org/tip/a5846e215bd47f61133383822422c683600efa7a
Author: Ramkumar Ramachandra <arta...@gmail.com>
AuthorDate: Mon, 30 Dec 2013 13:32:35 +0530
Committer: Arnaldo Carvalho de Melo <ac...@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 <arta...@gmail.com>
Acked-by: Jiri Olsa <jo...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Link: http://lkml.kernel.org/r/1388390555-10808-1-gi...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@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;
}
--

tip-bot for Ramkumar Ramachandra

unread,
Jan 14, 2014, 11:50:04 AM1/14/14
to
Commit-ID: 01f10bc85f538cd681d0a3338b97a33f308d944b
Gitweb: http://git.kernel.org/tip/01f10bc85f538cd681d0a3338b97a33f308d944b
Author: Ramkumar Ramachandra <arta...@gmail.com>
AuthorDate: Mon, 30 Dec 2013 13:04:19 +0530
Committer: Arnaldo Carvalho de Melo <ac...@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 <arta...@gmail.com>
Acked-by: Jiri Olsa <jo...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Link: http://lkml.kernel.org/r/1388388861-7931-3-gi...@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <ac...@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)
@@ -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);
--
0 new messages