summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogesh Tillu <yogesh.tillu@linaro.org>2015-08-26 12:04:21 +0530
committerYogesh Tillu <yogesh.tillu@linaro.org>2015-09-14 17:56:57 +0530
commite910a6a03f4cf81a80cec31e55b4a7b362e1e539 (patch)
tree09c8e230b18fbab0aea6911fb2f7889a68dc74d3
parenta93ac4d3f9fcac9e9463c33c77ebd56d81667e46 (diff)
perf_*: Add compile time switch to measure max delay
This will add extra overhead if you want to track the max delay as well. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org>
-rw-r--r--Makefile4
-rw-r--r--perf_ev_open.c17
-rw-r--r--perf_rc_mmap.c17
3 files changed, 36 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 5fda546..e487026 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,11 @@
#
#SPDX-License-Identifier: BSD-3-Clause
+ifeq ($(MAX_DELAY), 1)
+CFLAGS ?= -O3 -DMAX_DELAY
+else
CFLAGS ?= -O3
+endif
CC = $(CROSS_COMPILE)gcc
INSTALL = /usr/bin/install
diff --git a/perf_ev_open.c b/perf_ev_open.c
index 86c23f9..1b95420 100644
--- a/perf_ev_open.c
+++ b/perf_ev_open.c
@@ -112,6 +112,10 @@ int main(int ac, char *argv[])
int *b = NULL;
int i, pre_loop_res, post_loop_res, sum = 0;
unsigned long s_period = 1000000;
+#ifdef MAX_DELAY
+ unsigned long tmp_value = 0;
+ unsigned long max_value = 0;
+#endif
while ((option = getopt(ac, argv, "c:n:s:")) != -1) {
switch (option) {
@@ -156,7 +160,14 @@ int main(int ac, char *argv[])
time_start = cpucycles();
for (i = 0; i < 1000; i++) {
sum = loop(a, b, len);
+#ifndef MAX_DELAY
cpucycles();
+#else
+ tmp_value = cpucycles();
+ if ( max_value < tmp_value ) {
+ max_value = tmp_value;
+ }
+#endif
}
time_end = cpucycles();
@@ -173,7 +184,11 @@ int main(int ac, char *argv[])
/* ---------------------------------- */
ioctl(fddev, PERF_EVENT_IOC_DISABLE, 0);
post_loop_res = abs(time_end-time_start)/1000;
- printf("\t%s Counter[%d] Delay[cpucycles]=%d overflows=%d\n", argv[0], cnt, abs(post_loop_res - pre_loop_res),overflow);
+#ifndef MAX_DELAY
+ printf("\t%s Counter[%d] avg delay[cpucycles]=%d overflows=%d\n", argv[0], cnt, abs(post_loop_res - pre_loop_res),overflow);
+#else
+ printf("\t%s Counter[%d] max delay[cpucycles]=%ld avg delay[cpucycles]=%d Overflows=%d\n", argv[0], cnt, max_value, abs(post_loop_res - pre_loop_res),overflow);
+#endif
free(a);
free(b);
close(fddev);
diff --git a/perf_rc_mmap.c b/perf_rc_mmap.c
index 7cfc0d1..b87c627 100644
--- a/perf_rc_mmap.c
+++ b/perf_rc_mmap.c
@@ -144,6 +144,10 @@ int main(int ac, char *argv[])
int i, pre_loop_res, post_loop_res, sum = 0;
void *addr; /* mmaped address */
unsigned long start_count, stop_count, s_period=1000000;
+#ifdef MAX_DELAY
+ unsigned long tmp_value = 0;
+ unsigned long max_value = 0;
+#endif
while ((option = getopt(ac, argv, "c:n:s:")) != -1) {
switch (option) {
@@ -201,7 +205,14 @@ int main(int ac, char *argv[])
start_count = mmap_read_self(addr);
for (i = 0; i < 1000; i++) {
sum = loop(a, b, len);
+#ifndef MAX_DELAY
mmap_read_self(addr);
+#else
+ tmp_value = mmap_read_self(addr);
+ if ( max_value < tmp_value ) {
+ max_value = tmp_value;
+ }
+#endif
}
stop_count = mmap_read_self(addr);
@@ -217,7 +228,11 @@ int main(int ac, char *argv[])
ioctl(fddev, PERF_EVENT_IOC_DISABLE, 0);
/* --------------------End Critical section-------------- */
post_loop_res = abs(stop_count-start_count)/1000;
- printf("\t%s Counter[%d] Delay[cpucycles]=%d Overflows=%d\n", argv[0], cnt, abs(post_loop_res - pre_loop_res),overflow);
+#ifndef MAX_DELAY
+ printf("\t%s Counter[%d] avg delay[cpucycles]=%d Overflows=%d\n", argv[0], cnt, abs(post_loop_res - pre_loop_res),overflow);
+#else
+ printf("\t%s Counter[%d] max delay[cpucycles]=%ld avg delay[cpucycles]=%d Overflows=%d\n", argv[0], cnt, max_value, abs(post_loop_res - pre_loop_res),overflow);
+#endif
munmap(addr, page_size);
free(a);
free(b);