perf annotate: Introduce annotation_line__max_percent()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 15 Mar 2018 20:04:53 +0000 (17:04 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 20 Mar 2018 16:19:30 +0000 (13:19 -0300)
Out of the annotate_browser__write() routine, to be used in the --stdio2
mode.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-0he0wyy4haswqi1qb35x37do@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/annotate.c
tools/perf/util/annotate.c
tools/perf/util/annotate.h

index ab21739f27ae3716bd3c593c081cff830d041192..05f79f36e906940a538bec7d5adffdb9d7a43806 100644 (file)
@@ -117,15 +117,10 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
        int width = browser->width, printed;
        int i, pcnt_width = annotation__pcnt_width(notes),
               cycles_width = annotation__cycles_width(notes);
-       double percent_max = 0.0;
+       double percent_max = annotation_line__max_percent(al, notes);
        char bf[256];
        bool show_title = false;
 
-       for (i = 0; i < notes->nr_events; i++) {
-               if (al->samples[i].percent > percent_max)
-                       percent_max = al->samples[i].percent;
-       }
-
        if ((row == 0) && (al->offset == -1 || percent_max == 0.0)) {
                if (notes->have_cycles) {
                        if (al->ipc == 0.0 && al->cycles == 0)
index 7ad6400a0d4f7f2dfb820002533f41f2d7eef1a8..3bd6f9b0147f651650a7321887238a70347e599f 100644 (file)
@@ -2184,6 +2184,20 @@ bool ui__has_annotation(void)
        return use_browser == 1 && perf_hpp_list.sym;
 }
 
+
+double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes)
+{
+       double percent_max = 0.0;
+       int i;
+
+       for (i = 0; i < notes->nr_events; i++) {
+               if (al->samples[i].percent > percent_max)
+                       percent_max = al->samples[i].percent;
+       }
+
+       return percent_max;
+}
+
 int symbol__annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel,
                      struct annotation_options *options, struct arch **parch)
 {
index f93c805473f9f467c1addb08fc92e1c08ac0032f..83484e236f3373ada29839ed1f7f90fa81a4c954 100644 (file)
@@ -124,6 +124,9 @@ bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym);
 void disasm_line__free(struct disasm_line *dl);
 struct annotation_line *
 annotation_line__next(struct annotation_line *pos, struct list_head *head);
+
+double annotation_line__max_percent(struct annotation_line *al, struct annotation *notes);
+
 int disasm_line__scnprintf(struct disasm_line *dl, char *bf, size_t size, bool raw);
 size_t disasm__fprintf(struct list_head *head, FILE *fp);
 void symbol__calc_percent(struct symbol *sym, struct perf_evsel *evsel);