|
|
|
[PATCH 2/6 -tip] perf stat: treat same behaviour for all CYCLES and CLOCKS | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
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@xxxxxxxxx>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Site Home] [Other Archives] [Linux Kernel Newbies] [Fedora Kernel] [Linux Kernel Testers] [Linux SH] [Linux Omap] [Linux Kbuild] [Linux Tape] [Linux Input] [Linux Kernel Janitors] [Linux Kernel Packagers] [Linux Doc] [Linux Man Pages] [Linux API] [Linux Modules] [Linux Standards] [Kernel Announce] [Memory] [Netdev] [Git] [Linux PCI] [Linux I2C] [Linux NUMA] [Netfilter] [Netfilter Devel] [SELinux] [Bugtraq] [FIO] [Linux Serial] [Linux PPP] [Linux ISDN] [Linux Next] [Kernel Stable Commits] [Linux Tip Commits] [Kernel MM Commits] [Linux Security Module] [Ext3] [Ext4] [Linux BTRFS] [Linux XFS] [Linux NFS] [Linux Cachefs] [Reiser FS] [Initramfs] [Fastboot] [Linux RT Users] [Linux Virtualization] [LVS Devel] [Hot Plug] [KVM] [KVM PPC] [KVM ia64] [Linux Containers] [Util Linux NG] [Sk Drivers] [Wireless] [Linux Bluetooth] [Bluez Devel] [Ethernet Bridging] [Embedded Linux] [Sparse] [Linux Arch] [Linux ACPI] [Linux IBM ACPI] [Linux OpenGL] [CPU Freq] [Linux Power Management] [Linux DCCP] [Linux SCTP] [ALSA Devel] [Linux USB] [Large Format Photos] [DVD Store] [Tux] [Gimp] [Yosemite National Park Forum] [Linux PA RISC] [MIPS Linux] [IBM S/390 Linux] [ARM Linux] [ARM Kernel] [Sparc Linux] [Linux Security] [Linux Sound] [Linux Media] [Video 4 Linux] [Linux for the blind] [Linux RAID] [Linux ATA RAID] [Linux Clusters] [Linux SCSI] [Linux SCSI Target Infrastructure] [Linux IDE] [Linux SMP] [Linux AXP] [Linux Alpha] [Linux M68K] [Linux ia64] [Linux 8086] [Linux x86_64] [Linux Config] [Linux Apps] [Linux MSDOS] [Linux X.25] [Linux Crypto] [DM Crypt] [Linux Btrace] [Utrace Devel] [Yosemite Photos] [Linux C Programming] [Linux Assembly] [Dash] [DWARVES] [Older Kernel Mail]
![]() |
![]() |