CHECK-ATTRS is useful :
1. for multiple attrs checking
2. avoid repetition of PERF-TYPE- and PERF-COUNT- and save space
3. avoids line breakage
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
-diff
+#define CHECK-ATTRS(t, c, counter)
+ (attrs[counter].type == PERF-TYPE-##t &&
+ attrs[counter].config == PERF-COUNT-##c)
+
#define ERR-PERF-OPEN
"Error: counter %d, sys-perf-counter-open() syscall returned with %d (%s)n"
@@ -191,11 +195,9 @@ static void read-counter(int counter)
/*
* Save the full runtime - to allow normalization during printout:
*/
- if (attrs[counter].type == PERF-TYPE-SOFTWARE &&
- attrs[counter].config == PERF-COUNT-SW-TASK-CLOCK)
+ if (CHECK-ATTRS(SOFTWARE, SW-TASK-CLOCK, counter))
runtime-nsecs[run-idx] = count[0];
- if (attrs[counter].type == PERF-TYPE-HARDWARE &&
- attrs[counter].config == PERF-COUNT-HW-CPU-CYCLES)
+ if (CHECK-ATTRS(HARDWARE, HW-CPU-CYCLES, counter))
runtime-cycles[run-idx] = count[0];
}
@@ -254,9 +256,7 @@ static void nsec-printout(int counter, u64 *count, u64 *noise)
fprintf(stderr, " %14.6f %-24s", msecs, event-name(counter));
- if (attrs[counter].type == PERF-TYPE-SOFTWARE &&
- attrs[counter].config == PERF-COUNT-SW-TASK-CLOCK) {
-
+ if (CHECK-ATTRS(SOFTWARE, SW-TASK-CLOCK, counter)) {
if (walltime-nsecs-avg)
fprintf(stderr, " # %10.3f CPUs ",
(double)count[0] / (double)walltime-nsecs-avg);
@@ -269,9 +269,7 @@ static void abs-printout(int counter, u64 *count, u64 *noise)
fprintf(stderr, " %14Ld %-24s", count[0], event-name(counter));
if (runtime-cycles-avg &&
- attrs[counter].type == PERF-TYPE-HARDWARE &&
- attrs[counter].config == PERF-COUNT-HW-INSTRUCTIONS) {
-
+ CHECK-ATTRS(HARDWARE, HW-INSTRUCTIONS, counter)) {
fprintf(stderr, " # %10.3f IPC ",
(double)count[0] / (double)runtime-cycles-avg);
} else {
Re: PATCH -tip - perf stat: define CHECK_ATTRS for easy attrs checking by Ingo Molnar on
2009-06-30T10:09:32+00:00
* Jaswinder Singh Rajput <jaswinder@kernel.org> wrote:
> CHECK-ATTRS is useful :
> 1. for multiple attrs checking
> 2. avoid repetition of PERF-TYPE- and PERF-COUNT- and save space
> 3. avoids line breakage
>
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> -looks good except that the name should be something like
MATCH-EVENT() not CHECK-ATTRS().
Ingo
Re: PATCH -tip - perf stat: define CHECK_ATTRS for easy attrs checking by Jaswinder Singh Rajput on
2009-06-30T13:10:45+00:00
On Tue, 2009-06-30 at 12:08 +0200, Ingo Molnar wrote:
> * Jaswinder Singh Rajput <jaswinder@kernel.org> wrote:
>
> > CHECK-ATTRS is useful :
> > 1. for multiple attrs checking
> > 2. avoid repetition of PERF-TYPE- and PERF-COUNT- and save space
> > 3. avoids line breakage
> >
> > Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
> > -[PATCH -tip] perf stat: define MATCH-EVENT for easy attrs checking
MATCH-EVENT is useful :
1. for multiple attrs checking
2. avoid repetition of PERF-TYPE- and PERF-COUNT- and save space
3. avoids line breakage
Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@gmail.com>
-diff
+#define MATCH-EVENT(t, c, counter)
+ (attrs[counter].type == PERF-TYPE-##t &&
+ attrs[counter].config == PERF-COUNT-##c)
+
#define ERR-PERF-OPEN
"Error: counter %d, sys-perf-counter-open() syscall returned with %d (%s)
"
@@ -191,11 +195,9 @@ static void read-counter(int counter)
/*
* Save the full runtime - to allow normalization during printout:
*/
- if (attrs[counter].type == PERF-TYPE-SOFTWARE &&
- attrs[counter].config == PERF-COUNT-SW-TASK-CLOCK)
+ if (MATCH-EVENT(SOFTWARE, SW-TASK-CLOCK, counter))
runtime-nsecs[run-idx] = count[0];
- if (attrs[counter].type == PERF-TYPE-HARDWARE &&
- attrs[counter].config == PERF-COUNT-HW-CPU-CYCLES)
+ if (MATCH-EVENT(HARDWARE, HW-CPU-CYCLES, counter))
runtime-cycles[run-idx] = count[0];
}
@@ -254,9 +256,7 @@ static void nsec-printout(int counter, u64 *count, u64 *noise)
fprintf(stderr, " %14.6f %-24s", msecs, event-name(counter));
- if (attrs[counter].type == PERF-TYPE-SOFTWARE &&
- attrs[counter].config == PERF-COUNT-SW-TASK-CLOCK) {
-
+ if (MATCH-EVENT(SOFTWARE, SW-TASK-CLOCK, counter)) {
if (walltime-nsecs-avg)
fprintf(stderr, " # %10.3f CPUs ",
(double)count[0] / (double)walltime-nsecs-avg);
@@ -269,9 +269,7 @@ static void abs-printout(int counter, u64 *count, u64 *noise)
fprintf(stderr, " %14Ld %-24s", count[0], event-name(counter));
if (runtime-cycles-avg &&
- attrs[counter].type == PERF-TYPE-HARDWARE &&
- attrs[counter].config == PERF-COUNT-HW-INSTRUCTIONS) {
-
+ MATCH-EVENT(HARDWARE, HW-INSTRUCTIONS, counter)) {
fprintf(stderr, " # %10.3f IPC ",
(double)count[0] / (double)runtime-cycles-avg);
} else {