提交 e779898a 编写于 作者: I Ingo Molnar

perf stat: Print out instructins/cycle metric

Before:

     7549326754  cycles               #    3201.811 M/sec
    10007594937  instructions         #    4244.408 M/sec

After:

     7542051194  cycles               #    3201.996 M/sec
    10007743852  instructions         #    4248.811 M/sec # 1.327 per cycle

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: NIngo Molnar <mingo@elte.hu>
上级 a14832ff
...@@ -83,6 +83,7 @@ static __u64 event_scaled[MAX_COUNTERS]; ...@@ -83,6 +83,7 @@ static __u64 event_scaled[MAX_COUNTERS];
static __u64 runtime_nsecs; static __u64 runtime_nsecs;
static __u64 walltime_nsecs; static __u64 walltime_nsecs;
static __u64 runtime_cycles;
static void create_perf_stat_counter(int counter) static void create_perf_stat_counter(int counter)
{ {
...@@ -177,6 +178,9 @@ static void read_counter(int counter) ...@@ -177,6 +178,9 @@ static void read_counter(int counter)
if (attrs[counter].type == PERF_TYPE_SOFTWARE && if (attrs[counter].type == PERF_TYPE_SOFTWARE &&
attrs[counter].config == PERF_COUNT_TASK_CLOCK) attrs[counter].config == PERF_COUNT_TASK_CLOCK)
runtime_nsecs = count[0]; runtime_nsecs = count[0];
if (attrs[counter].type == PERF_TYPE_HARDWARE &&
attrs[counter].config == PERF_COUNT_CPU_CYCLES)
runtime_cycles = count[0];
} }
/* /*
...@@ -214,6 +218,13 @@ static void print_counter(int counter) ...@@ -214,6 +218,13 @@ static void print_counter(int counter)
if (runtime_nsecs) if (runtime_nsecs)
fprintf(stderr, " # %11.3f M/sec", fprintf(stderr, " # %11.3f M/sec",
(double)count[0]/runtime_nsecs*1000.0); (double)count[0]/runtime_nsecs*1000.0);
if (runtime_cycles &&
attrs[counter].type == PERF_TYPE_HARDWARE &&
attrs[counter].config == PERF_COUNT_INSTRUCTIONS) {
fprintf(stderr, " # %1.3f per cycle",
(double)count[0] / (double)runtime_cycles);
}
} }
if (scaled) if (scaled)
fprintf(stderr, " (scaled from %.2f%%)", fprintf(stderr, " (scaled from %.2f%%)",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册