diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-04-02 13:20:20 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-04-03 09:23:18 -0400 |
commit | 967a464a7e6d939f0b0dbb4ee41bd3d515fa9a6d (patch) | |
tree | 2d113bf942a4c7a2bbce3d3af4786ddc159634b4 | |
parent | f016d24acd95660ca264e0424c8037391d165553 (diff) |
perf hists: Introduce hists__scnprint_title()
That is not use any struct hists_browser internals, so that it can be
shared with the other UIs and tools.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Martin Liška <mliska@suse.cz>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
Link: https://lkml.kernel.org/n/tip-w8mczjnqnbcj9yzfkv9ja6ro@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 15 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 6 |
2 files changed, 17 insertions, 4 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 2ac66011354f..c20f0ad22f34 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -2208,10 +2208,8 @@ static inline bool is_report_browser(void *timer) | |||
2208 | return timer == NULL; | 2208 | return timer == NULL; |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf, size_t size) | 2211 | int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq) |
2212 | { | 2212 | { |
2213 | struct hist_browser_timer *hbt = browser->hbt; | ||
2214 | struct hists *hists = browser->hists; | ||
2215 | char unit; | 2213 | char unit; |
2216 | int printed; | 2214 | int printed; |
2217 | const struct dso *dso = hists->dso_filter; | 2215 | const struct dso *dso = hists->dso_filter; |
@@ -2254,7 +2252,7 @@ static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf | |||
2254 | strstr(ev_name, "call-graph=no")) | 2252 | strstr(ev_name, "call-graph=no")) |
2255 | enable_ref = true; | 2253 | enable_ref = true; |
2256 | 2254 | ||
2257 | if (!is_report_browser(hbt)) | 2255 | if (show_freq) |
2258 | scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->attr.sample_freq); | 2256 | scnprintf(sample_freq_str, sizeof(sample_freq_str), " %d Hz,", evsel->attr.sample_freq); |
2259 | 2257 | ||
2260 | nr_samples = convert_unit(nr_samples, &unit); | 2258 | nr_samples = convert_unit(nr_samples, &unit); |
@@ -2285,6 +2283,15 @@ static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf | |||
2285 | if (socket_id > -1) | 2283 | if (socket_id > -1) |
2286 | printed += scnprintf(bf + printed, size - printed, | 2284 | printed += scnprintf(bf + printed, size - printed, |
2287 | ", Processor Socket: %d", socket_id); | 2285 | ", Processor Socket: %d", socket_id); |
2286 | |||
2287 | return printed; | ||
2288 | } | ||
2289 | |||
2290 | static int hists_browser__scnprintf_title(struct hist_browser *browser, char *bf, size_t size) | ||
2291 | { | ||
2292 | struct hist_browser_timer *hbt = browser->hbt; | ||
2293 | int printed = __hists__scnprintf_title(browser->hists, bf, size, !is_report_browser(hbt)); | ||
2294 | |||
2288 | if (!is_report_browser(hbt)) { | 2295 | if (!is_report_browser(hbt)) { |
2289 | struct perf_top *top = hbt->arg; | 2296 | struct perf_top *top = hbt->arg; |
2290 | 2297 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 32fbf26e0c18..fbabfd8a215d 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -504,5 +504,11 @@ int __hpp__slsmg_color_printf(struct perf_hpp *hpp, const char *fmt, ...); | |||
504 | int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp, | 504 | int __hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp, |
505 | struct perf_hpp_list *hpp_list); | 505 | struct perf_hpp_list *hpp_list); |
506 | int hists__fprintf_headers(struct hists *hists, FILE *fp); | 506 | int hists__fprintf_headers(struct hists *hists, FILE *fp); |
507 | int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool show_freq); | ||
508 | |||
509 | static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t size) | ||
510 | { | ||
511 | return __hists__scnprintf_title(hists, bf, size, true); | ||
512 | } | ||
507 | 513 | ||
508 | #endif /* __PERF_HIST_H */ | 514 | #endif /* __PERF_HIST_H */ |