Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349891
b: refs/heads/master
c: f4c8bae
h: refs/heads/master
i:
  349889: c3f994c
  349887: a564cca
v: v3
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Dec 9, 2012
1 parent 69e8af6 commit f0c6586
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 05472daa4d8ab88a071bfcaa3bb47473e4071848
refs/heads/master: f4c8bae1920c459b7b9c12363d11e8a588862e42
35 changes: 13 additions & 22 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,55 +184,46 @@ s64 perf_diff__compute_wdiff(struct hist_entry *he, struct hist_entry *pair)
return he->diff.wdiff;
}

static int formula_delta(struct hist_entry *he, char *buf, size_t size)
static int formula_delta(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size)
{
struct hist_entry *pair = hist_entry__next_pair(he);

if (!pair)
return -1;

return scnprintf(buf, size,
"(%" PRIu64 " * 100 / %" PRIu64 ") - "
"(%" PRIu64 " * 100 / %" PRIu64 ")",
he->stat.period, he->hists->stats.total_period,
pair->stat.period, pair->hists->stats.total_period);
}

static int formula_ratio(struct hist_entry *he, char *buf, size_t size)
static int formula_ratio(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size)
{
struct hist_entry *pair = hist_entry__next_pair(he);
double new_period = he->stat.period;
double old_period = pair ? pair->stat.period : 0;

if (!pair)
return -1;
double old_period = pair->stat.period;

return scnprintf(buf, size, "%.0F / %.0F", new_period, old_period);
}

static int formula_wdiff(struct hist_entry *he, char *buf, size_t size)
static int formula_wdiff(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size)
{
struct hist_entry *pair = hist_entry__next_pair(he);
u64 new_period = he->stat.period;
u64 old_period = pair ? pair->stat.period : 0;

if (!pair)
return -1;
u64 old_period = pair->stat.period;

return scnprintf(buf, size,
"(%" PRIu64 " * " "%" PRId64 ") - (%" PRIu64 " * " "%" PRId64 ")",
new_period, compute_wdiff_w2, old_period, compute_wdiff_w1);
}

int perf_diff__formula(char *buf, size_t size, struct hist_entry *he)
int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size)
{
switch (compute) {
case COMPUTE_DELTA:
return formula_delta(he, buf, size);
return formula_delta(he, pair, buf, size);
case COMPUTE_RATIO:
return formula_ratio(he, buf, size);
return formula_ratio(he, pair, buf, size);
case COMPUTE_WEIGHTED_DIFF:
return formula_wdiff(he, buf, size);
return formula_wdiff(he, pair, buf, size);
default:
BUG_ON(1);
}
Expand Down
5 changes: 4 additions & 1 deletion trunk/tools/perf/ui/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,13 @@ static int hpp__width_formula(struct perf_hpp *hpp __maybe_unused)

static int hpp__entry_formula(struct perf_hpp *hpp, struct hist_entry *he)
{
struct hist_entry *pair = hist_entry__next_pair(he);
const char *fmt = symbol_conf.field_sep ? "%s" : "%-70s";
char buf[96] = " ";

perf_diff__formula(buf, sizeof(buf), he);
if (pair)
perf_diff__formula(he, pair, buf, sizeof(buf));

return scnprintf(hpp->buf, hpp->size, fmt, buf);
}

Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ unsigned int hists__sort_list_width(struct hists *self);
double perf_diff__compute_delta(struct hist_entry *he, struct hist_entry *pair);
double perf_diff__compute_ratio(struct hist_entry *he, struct hist_entry *pair);
s64 perf_diff__compute_wdiff(struct hist_entry *he, struct hist_entry *pair);
int perf_diff__formula(char *buf, size_t size, struct hist_entry *he);
int perf_diff__formula(struct hist_entry *he, struct hist_entry *pair,
char *buf, size_t size);
double perf_diff__period_percent(struct hist_entry *he, u64 period);
#endif /* __PERF_HIST_H */

0 comments on commit f0c6586

Please sign in to comment.