Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338974
b: refs/heads/master
c: b821c73
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo committed Nov 8, 2012
1 parent facb129 commit e2a467a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 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: ff6f7778a66edc033044a6baa2459ce79519e571
refs/heads/master: b821c7325354c589ccc9611cf9e6b0d7490ed6a6
21 changes: 12 additions & 9 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static double get_period_percent(struct hist_entry *he, u64 period)

double perf_diff__compute_delta(struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
double new_percent = get_period_percent(he, he->stat.period);
double old_percent = pair ? get_period_percent(pair, pair->stat.period) : 0.0;

Expand All @@ -165,7 +165,7 @@ double perf_diff__compute_delta(struct hist_entry *he)

double perf_diff__compute_ratio(struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
double new_period = he->stat.period;
double old_period = pair ? pair->stat.period : 0;

Expand All @@ -176,7 +176,7 @@ double perf_diff__compute_ratio(struct hist_entry *he)

s64 perf_diff__compute_wdiff(struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
u64 new_period = he->stat.period;
u64 old_period = pair ? pair->stat.period : 0;

Expand All @@ -193,7 +193,7 @@ s64 perf_diff__compute_wdiff(struct hist_entry *he)

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

if (!pair)
return -1;
Expand All @@ -207,7 +207,7 @@ static int formula_delta(struct hist_entry *he, char *buf, size_t size)

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

Expand All @@ -219,7 +219,7 @@ static int formula_ratio(struct hist_entry *he, char *buf, size_t size)

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

Expand Down Expand Up @@ -359,8 +359,11 @@ static void hists__match(struct hists *older, struct hists *newer)
struct rb_node *nd;

for (nd = rb_first(&newer->entries); nd; nd = rb_next(nd)) {
struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node);
pos->pair = hists__find_entry(older, pos);
struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node),
*pair = hists__find_entry(older, pos);

if (pair)
hist__entry_add_pair(pos, pair);
}
}

Expand Down Expand Up @@ -402,7 +405,7 @@ static void hists__baseline_only(struct hists *hists)
struct hist_entry *he = rb_entry(next, struct hist_entry, rb_node);

next = rb_next(&he->rb_node);
if (!he->pair) {
if (!hist_entry__next_pair(he)) {
rb_erase(&he->rb_node, &hists->entries);
hist_entry__free(he);
}
Expand Down
10 changes: 5 additions & 5 deletions trunk/tools/perf/ui/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int hpp__width_baseline(struct perf_hpp *hpp __maybe_unused)

static double baseline_percent(struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
struct hists *pair_hists = pair ? pair->hists : NULL;
double percent = 0.0;

Expand All @@ -179,7 +179,7 @@ static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he)
{
double percent = baseline_percent(he);

if (he->pair)
if (hist_entry__has_pairs(he))
return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent);
else
return scnprintf(hpp->buf, hpp->size, " ");
Expand All @@ -190,7 +190,7 @@ static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he)
double percent = baseline_percent(he);
const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";

if (he->pair || symbol_conf.field_sep)
if (hist_entry__has_pairs(he) || symbol_conf.field_sep)
return scnprintf(hpp->buf, hpp->size, fmt, percent);
else
return scnprintf(hpp->buf, hpp->size, " ");
Expand Down Expand Up @@ -248,7 +248,7 @@ static int hpp__width_period_baseline(struct perf_hpp *hpp __maybe_unused)

static int hpp__entry_period_baseline(struct perf_hpp *hpp, struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
u64 period = pair ? pair->stat.period : 0;
const char *fmt = symbol_conf.field_sep ? "%" PRIu64 : "%12" PRIu64;

Expand Down Expand Up @@ -354,7 +354,7 @@ static int hpp__width_displ(struct perf_hpp *hpp __maybe_unused)
static int hpp__entry_displ(struct perf_hpp *hpp,
struct hist_entry *he)
{
struct hist_entry *pair = he->pair;
struct hist_entry *pair = hist_entry__next_pair(he);
long displacement = pair ? pair->position - he->position : 0;
const char *fmt = symbol_conf.field_sep ? "%s" : "%6.6s";
char buf[32] = " ";
Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template)
he->ms.map->referenced = true;
if (symbol_conf.use_callchain)
callchain_init(he->callchain);

INIT_LIST_HEAD(&he->pairs.node);
}

return he;
Expand Down
27 changes: 23 additions & 4 deletions trunk/tools/perf/util/sort.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ struct hist_entry_diff {
struct hist_entry {
struct rb_node rb_node_in;
struct rb_node rb_node;
union {
struct list_head node;
struct list_head head;
} pairs;
struct he_stat stat;
struct map_symbol ms;
struct thread *thread;
Expand All @@ -96,15 +100,30 @@ struct hist_entry {
char *srcline;
struct symbol *parent;
unsigned long position;
union {
struct hist_entry *pair;
struct rb_root sorted_chain;
};
struct rb_root sorted_chain;
struct branch_info *branch_info;
struct hists *hists;
struct callchain_root callchain[0];
};

static inline bool hist_entry__has_pairs(struct hist_entry *he)
{
return !list_empty(&he->pairs.node);
}

static inline struct hist_entry *hist_entry__next_pair(struct hist_entry *he)
{
if (hist_entry__has_pairs(he))
return list_entry(he->pairs.node.next, struct hist_entry, pairs.node);
return NULL;
}

static inline void hist__entry_add_pair(struct hist_entry *he,
struct hist_entry *pair)
{
list_add_tail(&he->pairs.head, &pair->pairs.node);
}

enum sort_type {
SORT_PID,
SORT_COMM,
Expand Down

0 comments on commit e2a467a

Please sign in to comment.