Skip to contentSkip to conversation

perf stat: Add -n/--null option to run without counters

tip:perfcounters/urgent tip-bot for Ingo Molnar 2 participants 3 messages Jun 27, 2009 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Gitweb:     http://git.kernel.org/tip/0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Author:     Ingo Molnar <[email protected]>
AuthorDate: Sat, 27 Jun 2009 06:10:30 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 27 Jun 2009 06:11:24 +0200

perf stat: Add -n/--null option to run without counters

Allow a no-counters run. This can be useful to measure just elapsed wall-clock time - or to assess the raw overhead of perf stat itself, without running any counters.

Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/builtin-stat.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/builtin-stat.c +4 -1
index 8420ec5..cdcd058 100644
@@ -70,6 +70,7 @@ static int			run_count			=  1;
 static int			inherit				=  1;
 static int			scale				=  1;
 static int			target_pid			= -1;
+static int			null_run			=  0;
 
 static int			fd[MAX_NR_CPUS][MAX_COUNTERS];
 
@@ -461,6 +462,8 @@ static const struct option options[] = {
 		    "be more verbose (show counter open errors, etc)"),
 	OPT_INTEGER('r', "repeat", &run_count,
 		    "repeat command and print average + stddev (max: 100)"),
+	OPT_BOOLEAN('n', "null", &null_run,
+		    "null run - dont start any counters"),
 	OPT_END()
 };
 
@@ -476,7 +479,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	if (run_count <= 0 || run_count > MAX_RUN)
 		usage_with_options(stat_usage, options);
 
-	if (!nr_counters)
+	if (!null_run && !nr_counters)
 		nr_counters = 8;
 
 	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
#1 lore raw
Quoted 7 lines · tip-bot for Ingo Molnar
Commit-ID:  0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Gitweb:     http://git.kernel.org/tip/0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Author:     Ingo Molnar <[email protected]>
AuthorDate: Sat, 27 Jun 2009 06:10:30 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 27 Jun 2009 06:11:24 +0200
Quoted 6 lines

perf stat: Add -n/--null option to run without counters

Allow a no-counters run. This can be useful to measure just elapsed wall-clock time - or to assess the raw overhead of perf stat itself, without running any counters.

Why it better then $ time <command>

Any way this patch is broken.

Why you are allocating :
memcpy(attrs, default_attrs, sizeof(attrs)); when null_run is set.

To get better picture and solution, Please check [PATCH] perf stat: fix default attrs and nr_counters

which I send in "Re: [PATCH -tip] perf_counter tools: add support to set of multiple events in one short" send on Fri, 26 Jun 2009 18:08:40 +0530

Thanks,

--
JSR

Quoted 47 lines

Cc: Peter Zijlstra <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
LKML-Reference: <new-submission>

---
 tools/perf/builtin-stat.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
tools/perf/builtin-stat.c +4 -2
index 8420ec5..cdcd058 100644
@@ -70,6 +70,7 @@ static int			run_count			=  1;
 static int			inherit				=  1;
 static int			scale				=  1;
 static int			target_pid			= -1;
+static int			null_run			=  0;
 
 static int			fd[MAX_NR_CPUS][MAX_COUNTERS];
 
@@ -461,6 +462,8 @@ static const struct option options[] = {
 		    "be more verbose (show counter open errors, etc)"),
 	OPT_INTEGER('r', "repeat", &run_count,
 		    "repeat command and print average + stddev (max: 100)"),
+	OPT_BOOLEAN('n', "null", &null_run,
+		    "null run - dont start any counters"),
 	OPT_END()
 };
 
@@ -476,7 +479,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix)
 	if (run_count <= 0 || run_count > MAX_RUN)
 		usage_with_options(stat_usage, options);
 
-	if (!nr_counters)
+	if (!null_run && !nr_counters)
 		nr_counters = 8;
 
 	nr_cpus = sysconf(_SC_NPROCESSORS_ONLN);
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 8 lines · Jaswinder Singh Rajput
Quoted 7 lines · tip-bot for Ingo Molnar
Commit-ID:  0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Gitweb:     http://git.kernel.org/tip/0cfb7a13b8e4e0afd4b856156ab16a182de7505b
Author:     Ingo Molnar <[email protected]>
AuthorDate: Sat, 27 Jun 2009 06:10:30 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 27 Jun 2009 06:11:24 +0200
Quoted 8 lines
Quoted 6 lines

perf stat: Add -n/--null option to run without counters

Allow a no-counters run. This can be useful to measure just elapsed wall-clock time - or to assess the raw overhead of perf stat itself, without running any counters.

Why it better then $ time <command>

For example can 'time' do average and standard deviation measurements, like:

	perf stat --repeat 10 --null /bin/true

?

Also, --null can be used to validate 'perf stat'.

Quoted 4 lines

Any way this patch is broken.

Why you are allocating :
memcpy(attrs, default_attrs, sizeof(attrs)); when null_run is set.

a memcpy is not 'allocating' anything. What do you mean?

The memcpy itself could be unnecessary. Is it a big problem?

What exactly is 'broken' about it? It's a straightforward feature.

Quoted 6 lines

To get better picture and solution, Please check [PATCH] perf
stat: fix default attrs and nr_counters

which I send in "Re: [PATCH -tip] perf_counter tools: add support to set of multiple events in one short" send on Fri, 26 Jun 2009 18:08:40 +0530

When you send new patches you should change the subject line.

Also, that patch mixes in some other changes that look wrong. Anyway, please resubmit as standalone patch if you think that something is broken.

Ingo