|
@@ -654,14 +654,15 @@ struct disasm_line *disasm__get_next_ip_line(struct list_head *head, struct disa
|
|
|
}
|
|
|
|
|
|
double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
|
|
|
- s64 end, const char **path)
|
|
|
+ s64 end, const char **path, u64 *nr_samples)
|
|
|
{
|
|
|
struct source_line *src_line = notes->src->lines;
|
|
|
double percent = 0.0;
|
|
|
+ *nr_samples = 0;
|
|
|
|
|
|
if (src_line) {
|
|
|
size_t sizeof_src_line = sizeof(*src_line) +
|
|
|
- sizeof(src_line->p) * (src_line->nr_pcnt - 1);
|
|
|
+ sizeof(src_line->samples) * (src_line->nr_pcnt - 1);
|
|
|
|
|
|
while (offset < end) {
|
|
|
src_line = (void *)notes->src->lines +
|
|
@@ -670,7 +671,8 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
|
|
|
if (*path == NULL)
|
|
|
*path = src_line->path;
|
|
|
|
|
|
- percent += src_line->p[evidx].percent;
|
|
|
+ percent += src_line->samples[evidx].percent;
|
|
|
+ *nr_samples += src_line->samples[evidx].nr;
|
|
|
offset++;
|
|
|
}
|
|
|
} else {
|
|
@@ -680,8 +682,10 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
|
|
|
while (offset < end)
|
|
|
hits += h->addr[offset++];
|
|
|
|
|
|
- if (h->sum)
|
|
|
+ if (h->sum) {
|
|
|
+ *nr_samples = hits;
|
|
|
percent = 100.0 * hits / h->sum;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return percent;
|
|
@@ -696,8 +700,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|
|
|
|
|
if (dl->offset != -1) {
|
|
|
const char *path = NULL;
|
|
|
+ u64 nr_samples;
|
|
|
double percent, max_percent = 0.0;
|
|
|
double *ppercents = &percent;
|
|
|
+ u64 *psamples = &nr_samples;
|
|
|
int i, nr_percent = 1;
|
|
|
const char *color;
|
|
|
struct annotation *notes = symbol__annotation(sym);
|
|
@@ -710,8 +716,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|
|
if (perf_evsel__is_group_event(evsel)) {
|
|
|
nr_percent = evsel->nr_members;
|
|
|
ppercents = calloc(nr_percent, sizeof(double));
|
|
|
- if (ppercents == NULL)
|
|
|
+ psamples = calloc(nr_percent, sizeof(u64));
|
|
|
+ if (ppercents == NULL || psamples == NULL) {
|
|
|
return -1;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < nr_percent; i++) {
|
|
@@ -719,9 +727,10 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|
|
notes->src->lines ? i : evsel->idx + i,
|
|
|
offset,
|
|
|
next ? next->offset : (s64) len,
|
|
|
- &path);
|
|
|
+ &path, &nr_samples);
|
|
|
|
|
|
ppercents[i] = percent;
|
|
|
+ psamples[i] = nr_samples;
|
|
|
if (percent > max_percent)
|
|
|
max_percent = percent;
|
|
|
}
|
|
@@ -759,8 +768,14 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|
|
|
|
|
for (i = 0; i < nr_percent; i++) {
|
|
|
percent = ppercents[i];
|
|
|
+ nr_samples = psamples[i];
|
|
|
color = get_percent_color(percent);
|
|
|
- color_fprintf(stdout, color, " %7.2f", percent);
|
|
|
+
|
|
|
+ if (symbol_conf.show_total_period)
|
|
|
+ color_fprintf(stdout, color, " %7" PRIu64,
|
|
|
+ nr_samples);
|
|
|
+ else
|
|
|
+ color_fprintf(stdout, color, " %7.2f", percent);
|
|
|
}
|
|
|
|
|
|
printf(" : ");
|
|
@@ -770,6 +785,9 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|
|
if (ppercents != &percent)
|
|
|
free(ppercents);
|
|
|
|
|
|
+ if (psamples != &nr_samples)
|
|
|
+ free(psamples);
|
|
|
+
|
|
|
} else if (max_lines && printed >= max_lines)
|
|
|
return 1;
|
|
|
else {
|
|
@@ -1103,7 +1121,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin
|
|
|
ret = strcmp(iter->path, src_line->path);
|
|
|
if (ret == 0) {
|
|
|
for (i = 0; i < src_line->nr_pcnt; i++)
|
|
|
- iter->p[i].percent_sum += src_line->p[i].percent;
|
|
|
+ iter->samples[i].percent_sum += src_line->samples[i].percent;
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -1114,7 +1132,7 @@ static void insert_source_line(struct rb_root *root, struct source_line *src_lin
|
|
|
}
|
|
|
|
|
|
for (i = 0; i < src_line->nr_pcnt; i++)
|
|
|
- src_line->p[i].percent_sum = src_line->p[i].percent;
|
|
|
+ src_line->samples[i].percent_sum = src_line->samples[i].percent;
|
|
|
|
|
|
rb_link_node(&src_line->node, parent, p);
|
|
|
rb_insert_color(&src_line->node, root);
|
|
@@ -1125,9 +1143,9 @@ static int cmp_source_line(struct source_line *a, struct source_line *b)
|
|
|
int i;
|
|
|
|
|
|
for (i = 0; i < a->nr_pcnt; i++) {
|
|
|
- if (a->p[i].percent_sum == b->p[i].percent_sum)
|
|
|
+ if (a->samples[i].percent_sum == b->samples[i].percent_sum)
|
|
|
continue;
|
|
|
- return a->p[i].percent_sum > b->p[i].percent_sum;
|
|
|
+ return a->samples[i].percent_sum > b->samples[i].percent_sum;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
@@ -1179,7 +1197,7 @@ static void symbol__free_source_line(struct symbol *sym, int len)
|
|
|
int i;
|
|
|
|
|
|
sizeof_src_line = sizeof(*src_line) +
|
|
|
- (sizeof(src_line->p) * (src_line->nr_pcnt - 1));
|
|
|
+ (sizeof(src_line->samples) * (src_line->nr_pcnt - 1));
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
free_srcline(src_line->path);
|
|
@@ -1211,7 +1229,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
|
|
|
h_sum += h->sum;
|
|
|
}
|
|
|
nr_pcnt = evsel->nr_members;
|
|
|
- sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->p);
|
|
|
+ sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples);
|
|
|
}
|
|
|
|
|
|
if (!h_sum)
|
|
@@ -1231,10 +1249,10 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
|
|
|
|
|
|
for (k = 0; k < nr_pcnt; k++) {
|
|
|
h = annotation__histogram(notes, evidx + k);
|
|
|
- src_line->p[k].percent = 100.0 * h->addr[i] / h->sum;
|
|
|
+ src_line->samples[k].percent = 100.0 * h->addr[i] / h->sum;
|
|
|
|
|
|
- if (src_line->p[k].percent > percent_max)
|
|
|
- percent_max = src_line->p[k].percent;
|
|
|
+ if (src_line->samples[k].percent > percent_max)
|
|
|
+ percent_max = src_line->samples[k].percent;
|
|
|
}
|
|
|
|
|
|
if (percent_max <= 0.5)
|
|
@@ -1274,7 +1292,7 @@ static void print_summary(struct rb_root *root, const char *filename)
|
|
|
|
|
|
src_line = rb_entry(node, struct source_line, node);
|
|
|
for (i = 0; i < src_line->nr_pcnt; i++) {
|
|
|
- percent = src_line->p[i].percent_sum;
|
|
|
+ percent = src_line->samples[i].percent_sum;
|
|
|
color = get_percent_color(percent);
|
|
|
color_fprintf(stdout, color, " %7.2f", percent);
|
|
|
|