diff options
-rw-r--r-- | tools/perf/builtin-stat.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 184ff95ef4f5..80855090fd9f 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -83,6 +83,7 @@ static __u64 event_scaled[MAX_COUNTERS]; | |||
83 | 83 | ||
84 | static __u64 runtime_nsecs; | 84 | static __u64 runtime_nsecs; |
85 | static __u64 walltime_nsecs; | 85 | static __u64 walltime_nsecs; |
86 | static __u64 runtime_cycles; | ||
86 | 87 | ||
87 | static void create_perf_stat_counter(int counter) | 88 | static void create_perf_stat_counter(int counter) |
88 | { | 89 | { |
@@ -177,6 +178,9 @@ static void read_counter(int counter) | |||
177 | if (attrs[counter].type == PERF_TYPE_SOFTWARE && | 178 | if (attrs[counter].type == PERF_TYPE_SOFTWARE && |
178 | attrs[counter].config == PERF_COUNT_TASK_CLOCK) | 179 | attrs[counter].config == PERF_COUNT_TASK_CLOCK) |
179 | runtime_nsecs = count[0]; | 180 | runtime_nsecs = count[0]; |
181 | if (attrs[counter].type == PERF_TYPE_HARDWARE && | ||
182 | attrs[counter].config == PERF_COUNT_CPU_CYCLES) | ||
183 | runtime_cycles = count[0]; | ||
180 | } | 184 | } |
181 | 185 | ||
182 | /* | 186 | /* |
@@ -214,6 +218,13 @@ static void print_counter(int counter) | |||
214 | if (runtime_nsecs) | 218 | if (runtime_nsecs) |
215 | fprintf(stderr, " # %11.3f M/sec", | 219 | fprintf(stderr, " # %11.3f M/sec", |
216 | (double)count[0]/runtime_nsecs*1000.0); | 220 | (double)count[0]/runtime_nsecs*1000.0); |
221 | if (runtime_cycles && | ||
222 | attrs[counter].type == PERF_TYPE_HARDWARE && | ||
223 | attrs[counter].config == PERF_COUNT_INSTRUCTIONS) { | ||
224 | |||
225 | fprintf(stderr, " # %1.3f per cycle", | ||
226 | (double)count[0] / (double)runtime_cycles); | ||
227 | } | ||
217 | } | 228 | } |
218 | if (scaled) | 229 | if (scaled) |
219 | fprintf(stderr, " (scaled from %.2f%%)", | 230 | fprintf(stderr, " (scaled from %.2f%%)", |