Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 182338
b: refs/heads/master
c: 9c443df
h: refs/heads/master
v: v3
  • Loading branch information
Arnaldo Carvalho de Melo authored and Ingo Molnar committed Dec 30, 2009
1 parent 251ec33 commit 79fc73b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 32 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: cdbae31408cf39372402076cf2e189ec693daa71
refs/heads/master: 9c443dfdd31eddea6cbe6ee0ca469fbcc4e1dc3b
52 changes: 21 additions & 31 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,29 +82,19 @@ static void perf_session__insert_hist_entry_by_name(struct rb_root *root,
struct hist_entry *iter;

while (*p != NULL) {
int cmp;
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node);

cmp = strcmp(he->map->dso->name, iter->map->dso->name);
if (cmp > 0)
if (hist_entry__cmp(he, iter) < 0)
p = &(*p)->rb_left;
else if (cmp < 0)
else
p = &(*p)->rb_right;
else {
cmp = strcmp(he->sym->name, iter->sym->name);
if (cmp > 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
}

rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, root);
}

static void perf_session__resort_by_name(struct perf_session *self)
static void perf_session__resort_hist_entries(struct perf_session *self)
{
unsigned long position = 1;
struct rb_root tmp = RB_ROOT;
Expand All @@ -122,29 +112,28 @@ static void perf_session__resort_by_name(struct perf_session *self)
self->hists = tmp;
}

static void perf_session__set_hist_entries_positions(struct perf_session *self)
{
perf_session__output_resort(self, self->events_stats.total);
perf_session__resort_hist_entries(self);
}

static struct hist_entry *
perf_session__find_hist_entry_by_name(struct perf_session *self,
struct hist_entry *he)
perf_session__find_hist_entry(struct perf_session *self,
struct hist_entry *he)
{
struct rb_node *n = self->hists.rb_node;

while (n) {
struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node);
int cmp = strcmp(he->map->dso->name, iter->map->dso->name);
int64_t cmp = hist_entry__cmp(he, iter);

if (cmp > 0)
if (cmp < 0)
n = n->rb_left;
else if (cmp < 0)
else if (cmp > 0)
n = n->rb_right;
else {
cmp = strcmp(he->sym->name, iter->sym->name);
if (cmp > 0)
n = n->rb_left;
else if (cmp < 0)
n = n->rb_right;
else
return iter;
}
else
return iter;
}

return NULL;
Expand All @@ -155,11 +144,9 @@ static void perf_session__match_hists(struct perf_session *old_session,
{
struct rb_node *nd;

perf_session__resort_by_name(old_session);

for (nd = rb_first(&new_session->hists); nd; nd = rb_next(nd)) {
struct hist_entry *pos = rb_entry(nd, struct hist_entry, rb_node);
pos->pair = perf_session__find_hist_entry_by_name(old_session, pos);
pos->pair = perf_session__find_hist_entry(old_session, pos);
}
}

Expand All @@ -177,9 +164,12 @@ static int __cmd_diff(void)
ret = perf_session__process_events(session[i], &event_ops);
if (ret)
goto out_delete;
perf_session__output_resort(session[i], session[i]->events_stats.total);
}

perf_session__output_resort(session[1], session[1]->events_stats.total);
if (show_displacement)
perf_session__set_hist_entries_positions(session[0]);

perf_session__match_hists(session[0], session[1]);
perf_session__fprintf_hists(session[1], session[0],
show_displacement, stdout);
Expand Down

0 comments on commit 79fc73b

Please sign in to comment.