aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/perf_counter/builtin-stat.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-05-29 03:10:54 -0400
committerIngo Molnar <mingo@elte.hu>2009-05-29 03:46:45 -0400
commitbe1ac0d81d0e3ab655f8c8ade31fb860ef6aa186 (patch)
tree2d393b94655e3c2a1f2333556271d6b9eab2497a /Documentation/perf_counter/builtin-stat.c
parent2996f5ddb7ba8889caeeac65edafe48845106eaa (diff)
perf_counter tools: Also display time-normalized stat results
Add new column that normalizes counter results by 'nanoseconds spent running' unit. Before: Performance counter stats for '/home/mingo/hackbench': 10469.403605 task clock ticks (msecs) 75502 context switches (events) 9501 CPU migrations (events) 36158 pagefaults (events) 31975676185 CPU cycles (events) 26257738659 instructions (events) 108740581 cache references (events) 54606088 cache misses (events) Wall-clock time elapsed: 810.514504 msecs After: Performance counter stats for '/home/mingo/hackbench': 10469.403605 task clock ticks (msecs) 75502 context switches # 0.007 M/sec 9501 CPU migrations # 0.001 M/sec 36158 pagefaults # 0.003 M/sec 31975676185 CPU cycles # 3054.202 M/sec 26257738659 instructions # 2508.045 M/sec 108740581 cache references # 10.387 M/sec 54606088 cache misses # 5.216 M/sec Wall-clock time elapsed: 810.514504 msecs The advantage of that column is that it is characteristic of the execution workflow, regardless of runtime. Hence 'hackbench 10' will look similar to 'hackbench 15' - while the absolute counter values are very different. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: John Kacur <jkacur@redhat.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-stat.c')
-rw-r--r--Documentation/perf_counter/builtin-stat.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c
index 0c92eb725526..ef7e0e1192cb 100644
--- a/Documentation/perf_counter/builtin-stat.c
+++ b/Documentation/perf_counter/builtin-stat.c
@@ -74,6 +74,8 @@ static const unsigned int default_count[] = {
74static __u64 event_res[MAX_COUNTERS][3]; 74static __u64 event_res[MAX_COUNTERS][3];
75static __u64 event_scaled[MAX_COUNTERS]; 75static __u64 event_scaled[MAX_COUNTERS];
76 76
77static __u64 runtime_nsecs;
78
77static void create_perfstat_counter(int counter) 79static void create_perfstat_counter(int counter)
78{ 80{
79 struct perf_counter_hw_event hw_event; 81 struct perf_counter_hw_event hw_event;
@@ -165,6 +167,11 @@ static void read_counter(int counter)
165 ((double)count[0] * count[1] / count[2] + 0.5); 167 ((double)count[0] * count[1] / count[2] + 0.5);
166 } 168 }
167 } 169 }
170 /*
171 * Save the full runtime - to allow normalization during printout:
172 */
173 if (event_id[counter] == EID(PERF_TYPE_SOFTWARE, PERF_COUNT_TASK_CLOCK))
174 runtime_nsecs = count[0];
168} 175}
169 176
170/* 177/*
@@ -190,8 +197,11 @@ static void print_counter(int counter)
190 fprintf(stderr, " %14.6f %-20s (msecs)", 197 fprintf(stderr, " %14.6f %-20s (msecs)",
191 msecs, event_name(counter)); 198 msecs, event_name(counter));
192 } else { 199 } else {
193 fprintf(stderr, " %14Ld %-20s (events)", 200 fprintf(stderr, " %14Ld %-20s",
194 count[0], event_name(counter)); 201 count[0], event_name(counter));
202 if (runtime_nsecs)
203 fprintf(stderr, " # %12.3f M/sec",
204 (double)count[0]/runtime_nsecs*1000.0);
195 } 205 }
196 if (scaled) 206 if (scaled)
197 fprintf(stderr, " (scaled from %.2f%%)", 207 fprintf(stderr, " (scaled from %.2f%%)",