Messages in this thread Patch in this message | | | From | Andi Kleen <> | Subject | [PATCH 04/11] perf tools report: Parse time quantum | Date | Sun, 24 Feb 2019 07:37:15 -0800 |
| |
From: Andi Kleen <ak@linux.intel.com>
Many workloads change over time. perf report currently aggregates the whole time range reported in perf.data.
This patch adds an option for a time quantum to quantisize the perf.data over time.
This just adds the option, will be used in follow on patches for a time sort key.
Signed-off-by: Andi Kleen <ak@linux.intel.com> --- tools/perf/Documentation/perf-report.txt | 4 +++ tools/perf/builtin-report.c | 37 ++++++++++++++++++++++++ tools/perf/util/hist.c | 2 ++ tools/perf/util/hist.h | 2 ++ 4 files changed, 45 insertions(+)
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt index 51dbc519dbce..9ec1702bccdd 100644 --- a/tools/perf/Documentation/perf-report.txt +++ b/tools/perf/Documentation/perf-report.txt @@ -497,6 +497,10 @@ include::itrace.txt[] The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). +--time-quantum:: + Configure time quantum for time sort key. Default 100ms. + Accepts s, us, ms, ns units. + include::callchain-overhead-calculation.txt[] SEE ALSO diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bb8918a747ba..600e168f3b99 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -47,6 +47,7 @@ #include <errno.h> #include <inttypes.h> #include <regex.h> +#include "sane_ctype.h" #include <signal.h> #include <linux/bitmap.h> #include <linux/stringify.h> @@ -926,6 +927,39 @@ report_parse_callchain_opt(const struct option *opt, const char *arg, int unset) return parse_callchain_report_opt(arg); } +static int +parse_time_quantum(const struct option *opt, const char *arg, + int unset __maybe_unused) +{ + unsigned long *time_q = opt->value; + char *end; + + *time_q = strtoul(arg, &end, 0); + if (end == arg) + goto parse_err; + while (isspace(*end)) + end++; + if (*end == 0) + return 0; + if (!strcmp(end, "s")) { + *time_q *= 1000000000; + return 0; + } + if (!strcmp(end, "ms")) { + *time_q *= 1000000; + return 0; + } + if (!strcmp(end, "us")) { + *time_q *= 1000; + return 0; + } + if (!strcmp(end, "ns")) + return 0; +parse_err: + pr_err("Cannot parse time quantum `%s'\n", arg); + return -1; +} + int report_parse_ignore_callees_opt(const struct option *opt __maybe_unused, const char *arg, int unset __maybe_unused) @@ -1148,6 +1182,9 @@ int cmd_report(int argc, const char **argv) "Set percent type local/global-period/hits", annotate_parse_percent_type), OPT_BOOLEAN(0, "ns", &nanosecs, "Show times in nanosecs"), + OPT_CALLBACK(0, "time-quantum", &time_quantum, "time (ms|us|ns)", + "Set time quantum for time sort key (default 100ms)", + parse_time_quantum), OPT_END() }; struct perf_data data = { diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 669f961316f0..d25ca5bb91e6 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -20,6 +20,8 @@ #include <inttypes.h> #include <sys/param.h> +unsigned long time_quantum = 100000000; + static bool hists__filter_entry_by_dso(struct hists *hists, struct hist_entry *he); static bool hists__filter_entry_by_thread(struct hists *hists, diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 4af27fbab24f..8e602b486c5c 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h @@ -531,4 +531,6 @@ static inline int hists__scnprintf_title(struct hists *hists, char *bf, size_t s return __hists__scnprintf_title(hists, bf, size, true); } +extern unsigned long time_quantum; + #endif /* __PERF_HIST_H */ -- 2.17.2
| |