22 static char const *input_old =
"perf.data.old",
23 *input_new =
"perf.data";
24 static char diff__default_sort_order[] =
"dso,symbol";
26 static bool show_displacement;
28 static int hists__add_entry(
struct hists *
self,
45 pr_warning(
"problem processing %d event, skipping it.\n",
53 if (hists__add_entry(&evsel->
hists, &al, sample->
period)) {
54 pr_warning(
"problem incrementing symbol period, skipping event\n");
63 .sample = diff__process_sample_event,
69 .ordered_samples =
true,
70 .ordering_requires_timestamps =
true,
73 static void insert_hist_entry_by_name(
struct rb_root *root,
89 rb_link_node(&he->
rb_node, parent, p);
93 static void hists__name_resort(
struct hists *
self,
bool sort)
99 while (next !=
NULL) {
107 insert_hist_entry_by_name(&tmp, n);
135 static void hists__match(
struct hists *older,
struct hists *newer)
141 pos->
pair = hists__find_entry(older, pos);
151 if (perf_evsel__match2(evsel, e))
170 if (name || ((!name) && show_displacement))
171 hists__name_resort(hists, name);
175 static int __cmd_diff(
void)
178 #define older (session[0])
179 #define newer (session[1])
189 if (session[0] == NULL || session[1] == NULL)
192 for (i = 0; i < 2; ++
i) {
198 evlist_old = older->evlist;
199 evlist_new = newer->evlist;
201 perf_evlist__resort_hists(evlist_old,
true);
202 perf_evlist__resort_hists(evlist_new,
false);
207 evsel_old = evsel_match(evsel, evlist_old);
211 fprintf(stdout,
"%s# Event '%s'\n#\n", first ?
"" :
"\n",
216 hists__match(&evsel_old->
hists, &evsel->
hists);
221 for (i = 0; i < 2; ++
i)
228 static const char *
const diff_usage[] = {
229 "perf diff [<options>] [old_file] [new_file]",
235 "be more verbose (show symbol address, etc)"),
236 OPT_BOOLEAN(
'M',
"displacement", &show_displacement,
237 "Show position displacement relative to baseline"),
239 "dump raw trace in ASCII"),
242 "load module symbols - WARNING: use only with -k and LIVE kernel"),
244 "only consider symbols in these dsos"),
246 "only consider symbols in these comms"),
248 "only consider these symbols"),
250 "sort by key(s): pid, comm, dso, symbol, parent"),
252 "separator for columns, no spaces will be added between "
253 "columns '.' is reserved."),
255 "Look for files with symbols relative to this directory"),
259 static void ui_init(
void)
270 if (show_displacement)
288 input_old =
"perf.data.host";
289 input_new =
"perf.data.guest";