aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorTaeung Song <treeze.taeung@gmail.com>2017-07-19 17:36:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-21 07:23:49 -0400
commit8158683da3d30e0346275702a8e08f2b22726c45 (patch)
treeab218d3516ffc6a52bbbdbd4b777b4874a3a65ed /tools/perf/util/annotate.c
parent896bccd3cb8d95cbc565687715516009c5169e71 (diff)
perf annotate: Rename 'sum' to 'nr_samples' in struct sym_hist
To make it more clear that it is the sum of all the nr_samples fields in the addr[] entries, i.e.: sym_hist->nr_samples = sum(sym_hist->addr[0 .. symbol__size(sym)]->nr_samples) Committer notes: Taeung had renamed it to total_samples, but using nr_samples, as in the added explanation above, looks clearer and establishes the direct connection, making clear it is about the _number_ of samples. Signed-off-by: Taeung Song <treeze.taeung@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1500500211-16599-1-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c3829555ce1c..58c6b63ff049 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -713,7 +713,7 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
713 713
714 offset = addr - sym->start; 714 offset = addr - sym->start;
715 h = annotation__histogram(notes, evidx); 715 h = annotation__histogram(notes, evidx);
716 h->sum++; 716 h->nr_samples++;
717 h->addr[offset].nr_samples++; 717 h->addr[offset].nr_samples++;
718 718
719 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64 719 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
@@ -957,9 +957,9 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
957 while (offset < end) 957 while (offset < end)
958 hits += h->addr[offset++].nr_samples; 958 hits += h->addr[offset++].nr_samples;
959 959
960 if (h->sum) { 960 if (h->nr_samples) {
961 sample->nr_samples = hits; 961 sample->nr_samples = hits;
962 percent = 100.0 * hits / h->sum; 962 percent = 100.0 * hits / h->nr_samples;
963 } 963 }
964 } 964 }
965 965
@@ -1672,19 +1672,19 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1672 struct sym_hist *h = annotation__histogram(notes, evidx); 1672 struct sym_hist *h = annotation__histogram(notes, evidx);
1673 struct rb_root tmp_root = RB_ROOT; 1673 struct rb_root tmp_root = RB_ROOT;
1674 int nr_pcnt = 1; 1674 int nr_pcnt = 1;
1675 u64 h_sum = h->sum; 1675 u64 nr_samples = h->nr_samples;
1676 size_t sizeof_src_line = sizeof(struct source_line); 1676 size_t sizeof_src_line = sizeof(struct source_line);
1677 1677
1678 if (perf_evsel__is_group_event(evsel)) { 1678 if (perf_evsel__is_group_event(evsel)) {
1679 for (i = 1; i < evsel->nr_members; i++) { 1679 for (i = 1; i < evsel->nr_members; i++) {
1680 h = annotation__histogram(notes, evidx + i); 1680 h = annotation__histogram(notes, evidx + i);
1681 h_sum += h->sum; 1681 nr_samples += h->nr_samples;
1682 } 1682 }
1683 nr_pcnt = evsel->nr_members; 1683 nr_pcnt = evsel->nr_members;
1684 sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples); 1684 sizeof_src_line += (nr_pcnt - 1) * sizeof(src_line->samples);
1685 } 1685 }
1686 1686
1687 if (!h_sum) 1687 if (!nr_samples)
1688 return 0; 1688 return 0;
1689 1689
1690 src_line = notes->src->lines = calloc(len, sizeof_src_line); 1690 src_line = notes->src->lines = calloc(len, sizeof_src_line);
@@ -1694,7 +1694,7 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1694 start = map__rip_2objdump(map, sym->start); 1694 start = map__rip_2objdump(map, sym->start);
1695 1695
1696 for (i = 0; i < len; i++) { 1696 for (i = 0; i < len; i++) {
1697 u64 offset, nr_samples; 1697 u64 offset;
1698 double percent_max = 0.0; 1698 double percent_max = 0.0;
1699 1699
1700 src_line->nr_pcnt = nr_pcnt; 1700 src_line->nr_pcnt = nr_pcnt;
@@ -1704,8 +1704,8 @@ static int symbol__get_source_line(struct symbol *sym, struct map *map,
1704 1704
1705 h = annotation__histogram(notes, evidx + k); 1705 h = annotation__histogram(notes, evidx + k);
1706 nr_samples = h->addr[i].nr_samples; 1706 nr_samples = h->addr[i].nr_samples;
1707 if (h->sum) 1707 if (h->nr_samples)
1708 percent = 100.0 * nr_samples / h->sum; 1708 percent = 100.0 * nr_samples / h->nr_samples;
1709 1709
1710 if (percent > percent_max) 1710 if (percent > percent_max)
1711 percent_max = percent; 1711 percent_max = percent;
@@ -1777,7 +1777,7 @@ static void symbol__annotate_hits(struct symbol *sym, struct perf_evsel *evsel)
1777 if (h->addr[offset].nr_samples != 0) 1777 if (h->addr[offset].nr_samples != 0)
1778 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2, 1778 printf("%*" PRIx64 ": %" PRIu64 "\n", BITS_PER_LONG / 2,
1779 sym->start + offset, h->addr[offset].nr_samples); 1779 sym->start + offset, h->addr[offset].nr_samples);
1780 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->sum", h->sum); 1780 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->nr_samples", h->nr_samples);
1781} 1781}
1782 1782
1783int symbol__annotate_printf(struct symbol *sym, struct map *map, 1783int symbol__annotate_printf(struct symbol *sym, struct map *map,
@@ -1813,7 +1813,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map,
1813 width *= evsel->nr_members; 1813 width *= evsel->nr_members;
1814 1814
1815 graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n", 1815 graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples)\n",
1816 width, width, "Percent", d_filename, evsel_name, h->sum); 1816 width, width, "Percent", d_filename, evsel_name, h->nr_samples);
1817 1817
1818 printf("%-*.*s----\n", 1818 printf("%-*.*s----\n",
1819 graph_dotted_len, graph_dotted_len, graph_dotted_line); 1819 graph_dotted_len, graph_dotted_len, graph_dotted_line);
@@ -1877,10 +1877,10 @@ void symbol__annotate_decay_histogram(struct symbol *sym, int evidx)
1877 struct sym_hist *h = annotation__histogram(notes, evidx); 1877 struct sym_hist *h = annotation__histogram(notes, evidx);
1878 int len = symbol__size(sym), offset; 1878 int len = symbol__size(sym), offset;
1879 1879
1880 h->sum = 0; 1880 h->nr_samples = 0;
1881 for (offset = 0; offset < len; ++offset) { 1881 for (offset = 0; offset < len; ++offset) {
1882 h->addr[offset].nr_samples = h->addr[offset].nr_samples * 7 / 8; 1882 h->addr[offset].nr_samples = h->addr[offset].nr_samples * 7 / 8;
1883 h->sum += h->addr[offset].nr_samples; 1883 h->nr_samples += h->addr[offset].nr_samples;
1884 } 1884 }
1885} 1885}
1886 1886