Re: [PATCH v3 04/11] perf tools report: Parse time quantum
From: Jiri Olsa
Date: Mon Mar 04 2019 - 09:49:12 EST
On Thu, Feb 28, 2019 at 10:35:43AM -0800, Andi Kleen wrote:
SNIP
> +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;
> + if (*time_q == 0) {
> + pr_err("time quantum cannot be 0");
> + return -1;
> + }
> + 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 +1186,9 @@ int cmd_report(int argc, const char **argv)
> "Set percent type local/global-period/hits",
> annotate_parse_percent_type),
> OPT_BOOLEAN(0, "ns", &symbol_conf.nanosecs, "Show times in nanosecs"),
> + OPT_CALLBACK(0, "time-quantum", &symbol_conf.time_quantum, "time (ms|us|ns)",
missing 's' unit in ()
jirka