lkml.org 
[lkml]   [2009]   [Jul]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/6 -tip] perf stat: treat same behaviour for all CYCLES and CLOCKS
From
Date

For normalization also added SW_CPU_CLOCK and HW_BUS_CYCLES

For nsec_printout also added SW_CPU_CLOCK

Added helper functions to check counter unit as cycles and instructions

Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
---
tools/perf/builtin-stat.c | 49 +++++++++++++++++++++++++++++++-------------
1 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 6bf2b80..af61c29 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -144,6 +144,29 @@ static inline int nsec_counter(int counter)
}

/*
+ * Does the counter have cycles as a unit?
+ */
+static inline int cycle_counter(int counter)
+{
+ if (MATCH_EVENT(HARDWARE, HW_CPU_CYCLES, counter) ||
+ MATCH_EVENT(HARDWARE, HW_BUS_CYCLES, counter))
+ return 1;
+
+ return 0;
+}
+
+/*
+ * Does the counter have instructions as a unit?
+ */
+static inline int instruction_counter(int counter)
+{
+ if (MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter))
+ return 1;
+
+ return 0;
+}
+
+/*
* Read out the results of a single counter:
*/
static void read_counter(int counter)
@@ -191,9 +214,9 @@ static void read_counter(int counter)
/*
* Save the full runtime - to allow normalization during printout:
*/
- if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter))
+ if (nsec_counter(counter))
runtime_nsecs[run_idx] = count[0];
- if (MATCH_EVENT(HARDWARE, HW_CPU_CYCLES, counter))
+ else if (cycle_counter(counter))
runtime_cycles[run_idx] = count[0];
}

@@ -287,11 +310,10 @@ static void nsec_printout(int counter, u64 *count, u64 *noise)

fprintf(stderr, " %14.6f %-24s", msecs, event_name(counter));

- if (MATCH_EVENT(SOFTWARE, SW_TASK_CLOCK, counter)) {
- if (walltime_nsecs_avg)
- fprintf(stderr, " # %10.3f CPUs ",
- (double)count[0] / (double)walltime_nsecs_avg);
- }
+ if (nsec_counter(counter) && walltime_nsecs_avg)
+ fprintf(stderr, " # %10.3f CPUs ",
+ (double)count[0] / (double)walltime_nsecs_avg);
+
print_noise(count, noise);
}

@@ -299,16 +321,13 @@ static void abs_printout(int counter, u64 *count, u64 *noise)
{
fprintf(stderr, " %14Ld %-24s", count[0], event_name(counter));

- if (runtime_cycles_avg &&
- MATCH_EVENT(HARDWARE, HW_INSTRUCTIONS, counter)) {
+ if (instruction_counter(counter) && runtime_cycles_avg)
fprintf(stderr, " # %10.3f IPC ",
(double)count[0] / (double)runtime_cycles_avg);
- } else {
- if (runtime_nsecs_avg) {
- fprintf(stderr, " # %10.3f M/sec",
- (double)count[0]/runtime_nsecs_avg*1000.0);
- }
- }
+ else if (runtime_nsecs_avg)
+ fprintf(stderr, " # %10.3f M/sec",
+ (double)count[0]/runtime_nsecs_avg*1000.0);
+
print_noise(count, noise);
}

--
1.6.0.6




\
 
 \ /
  Last update: 2009-07-01 11:49    [W:0.101 / U:5.756 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site