public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: Re: [PATCH 9/9] perf stat: Display user and system time
Date: Mon, 23 Apr 2018 11:51:20 -0300	[thread overview]
Message-ID: <20180423145120.GH30324@kernel.org> (raw)
In-Reply-To: <20180423090823.32309-10-jolsa@kernel.org>

Em Mon, Apr 23, 2018 at 11:08:23AM +0200, Jiri Olsa escreveu:
> Adding the support to read rusage data once the
> workload is finished and display the system/user
> time values:
> 
>   $ perf stat --null ./perf bench sched pipe
>   ...
> 
>    Performance counter stats for './perf bench sched pipe':
> 
>        5.342599256 seconds time elapsed
> 
>        2.544434000 seconds user
>        4.549691000 seconds sys

Please write a setence or two explaining the above three timings, do it
nicely so that we can add it to the man page and avoid people scratching
heads :-)

All the other patches were applied, some to perf/urgent (fixes) the
remaining ones, new features, added to perf/core, up to Ingo to decide
where to merge when I get to ask him to pull.

- Arnaldo
 
> It works only in non -r mode.
> 
> Suggested-by: Ingo Molnar <mingo@kernel.org>
> Link: http://lkml.kernel.org/n/tip-t8k6d3gs8sz8zqnz3aslk5ro@git.kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>  tools/perf/builtin-stat.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
> index 2137c7d11767..9c987617c8e7 100644
> --- a/tools/perf/builtin-stat.c
> +++ b/tools/perf/builtin-stat.c
> @@ -80,6 +80,9 @@
>  #include <sys/stat.h>
>  #include <sys/wait.h>
>  #include <unistd.h>
> +#include <sys/time.h>
> +#include <sys/resource.h>
> +#include <sys/wait.h>
>  
>  #include "sane_ctype.h"
>  
> @@ -174,6 +177,8 @@ static const char		*output_name;
>  static int			output_fd;
>  static int			print_free_counters_hint;
>  static u64			*walltime_run;
> +static bool			ru_display			= false;
> +static struct rusage		ru_data;
>  
>  struct perf_stat {
>  	bool			 record;
> @@ -725,7 +730,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
>  					break;
>  			}
>  		}
> -		waitpid(child_pid, &status, 0);
> +		wait4(child_pid, &status, 0, &ru_data);
>  
>  		if (workload_exec_errno) {
>  			const char *emsg = str_error_r(workload_exec_errno, msg, sizeof(msg));
> @@ -1773,6 +1778,11 @@ static void print_table(FILE *output, int precision, double avg)
>  	fprintf(output, "\n%*s# Final result:\n", indent, "");
>  }
>  
> +static double timeval2double(struct timeval *t)
> +{
> +	return t->tv_sec + (double) t->tv_usec/USEC_PER_SEC;
> +}
> +
>  static void print_footer(void)
>  {
>  	double avg = avg_stats(&walltime_nsecs_stats) / NSEC_PER_SEC;
> @@ -1784,6 +1794,15 @@ static void print_footer(void)
>  
>  	if (run_count == 1) {
>  		fprintf(output, " %17.9f seconds time elapsed", avg);
> +
> +		if (ru_display) {
> +			double utime = timeval2double(&ru_data.ru_utime);
> +			double stime = timeval2double(&ru_data.ru_stime);
> +
> +			fprintf(output, "\n\n");
> +			fprintf(output, " %17.9f seconds user\n", utime);
> +			fprintf(output, " %17.9f seconds sys\n", stime);
> +		}
>  	} else {
>  		double sd = stddev_stats(&walltime_nsecs_stats) / NSEC_PER_SEC;
>  		/*
> @@ -2869,6 +2888,13 @@ int cmd_stat(int argc, const char **argv)
>  		goto out;
>  	}
>  
> +	/*
> +	 * Display user/system times only for single
> +	 * run and when there's specified tracee.
> +	 */
> +	if ((run_count == 1) && target__none(&target))
> +		ru_display = true;
> +
>  	if (output_fd < 0) {
>  		fprintf(stderr, "argument to --log-fd must be a > 0\n");
>  		parse_options_usage(stat_usage, stat_options, "log-fd", 0);
> -- 
> 2.13.6

  reply	other threads:[~2018-04-23 14:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23  9:08 [PATCH 0/9] perf tools: Assorted fixes Jiri Olsa
2018-04-23  9:08 ` [PATCH 1/9] perf check-headers.sh: Simplify arguments passing Jiri Olsa
2018-05-02 17:40   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 2/9] perf check-headers.sh: Add support to check 2 independent files Jiri Olsa
2018-04-23 14:28   ` Arnaldo Carvalho de Melo
2018-05-02 17:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 3/9] perf stat: Keep the / modifier separator in fallback Jiri Olsa
2018-04-23 14:16   ` Arnaldo Carvalho de Melo
2018-04-26  5:53   ` [tip:perf/urgent] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 4/9] perf tools: Fix pmu events parsing rule Jiri Olsa
2018-04-23 14:20   ` Arnaldo Carvalho de Melo
2018-04-23 14:25     ` Jiri Olsa
2018-04-26  5:54   ` [tip:perf/urgent] perf pmu: " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 5/9] perf tools: Disable write_backward for leader sampling group events Jiri Olsa
2018-04-23 14:23   ` Arnaldo Carvalho de Melo
2018-04-26  5:54   ` [tip:perf/urgent] perf evsel: " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 6/9] perf stat: Display time in precision based on std deviation Jiri Olsa
2018-04-23 14:40   ` Arnaldo Carvalho de Melo
2018-05-02 17:41   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 7/9] perf stat: Add --table option to display time of each run Jiri Olsa
2018-04-23 14:41   ` Arnaldo Carvalho de Melo
2018-04-23 15:29     ` Jiri Olsa
2018-05-02 17:42   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 8/9] perf stat: Display length strings of each run for --table option Jiri Olsa
2018-05-02 17:42   ` [tip:perf/core] " tip-bot for Jiri Olsa
2018-04-23  9:08 ` [PATCH 9/9] perf stat: Display user and system time Jiri Olsa
2018-04-23 14:51   ` Arnaldo Carvalho de Melo [this message]
2018-04-23 15:30     ` Jiri Olsa
2018-04-23 18:48 ` [PATCH 0/9] perf tools: Assorted fixes Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180423145120.GH30324@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox