summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYogesh Tillu <yogesh.tillu@linaro.org>2015-06-01 16:11:07 +0530
committerYogesh Tillu <yogesh.tillu@linaro.org>2015-06-01 21:08:27 +0530
commit3c6a1546e5de8da60181bb14954c63f16a035245 (patch)
tree2cf8f18ce7a7c7f5d754408caf664879a23dbd28
parentc2d000e20ceac2a1d8e6111f5a01def9dc294d0b (diff)
Added support for making absolute result
Signed-off-by: Yogesh Tillu <yogesh.tillu@linaro.org> Reviewed-by: Anders Roxell <anders.roxell@linaro.org>
-rw-r--r--perf_ev_open.c12
-rw-r--r--perf_rc_mmap.c13
2 files changed, 15 insertions, 10 deletions
diff --git a/perf_ev_open.c b/perf_ev_open.c
index 9b06586..bfc2fcd 100644
--- a/perf_ev_open.c
+++ b/perf_ev_open.c
@@ -17,6 +17,7 @@
#include <sys/syscall.h>
#include <linux/perf_event.h>
#include <getopt.h>
+#include <math.h>
static int fddev = -1;
@@ -81,7 +82,7 @@ int main(int ac, char *argv[])
int len = -1, cnt = -1;
int *a = NULL;
int *b = NULL;
- int i, result, sum = 0;
+ int i, pre_loop_res, post_loop_res, sum = 0;
while ((option = getopt(ac, argv, "c:n:")) != -1) {
switch (option) {
@@ -126,9 +127,9 @@ int main(int ac, char *argv[])
time_end = cpucycles();
/* ---------------------------------- */
- result = (time_end-time_start)/1000;
+ pre_loop_res = abs(time_end-time_start)/1000;
printf("\nsum=%d Avg count [ Loop + Read ] = %ld\n", sum,
- (time_end-time_start)/1000);
+ pre_loop_res);
time_start = time_end = 0;
/* --------------------Critical section-------------- */
time_start = cpucycles();
@@ -137,10 +138,11 @@ int main(int ac, char *argv[])
time_end = cpucycles();
/* ---------------------------------- */
+ post_loop_res = abs(time_end-time_start)/1000;
printf("sum=%d Avg count [ Loop ] = %ld\n", sum,
- (time_end-time_start)/1000);
+ post_loop_res);
printf("\n--------------------------------------------------------\n");
- printf("\tDelay[cpucycles]=%d", result-((time_end-time_start)/1000));
+ printf("\tDelay[cpucycles]=%d\n", abs(post_loop_res - pre_loop_res));
printf("\n--------------------------------------------------------\n");
free(a);
free(b);
diff --git a/perf_rc_mmap.c b/perf_rc_mmap.c
index 180ddd7..79d76ec 100644
--- a/perf_rc_mmap.c
+++ b/perf_rc_mmap.c
@@ -21,6 +21,8 @@
#include <errno.h>
#include <string.h>
#include <getopt.h>
+#include <math.h>
+
#define barrier() asm volatile("dmb ish" : : : "memory")
#define isb() asm volatile("isb" : : : "memory")
#define ARMV8_PMCNTENSET_EL0_ENABLE (1<<31) /**< Enable Perf count reg */
@@ -111,7 +113,7 @@ int main(int ac, char *argv[])
int *a = NULL;
int *b = NULL;
int len = -1, cnt = -1;
- int i, result, sum = 0;
+ int i, pre_loop_res, post_loop_res, sum = 0;
void *addr; /* mmaped address */
unsigned long start_count, stop_count;
@@ -168,9 +170,9 @@ int main(int ac, char *argv[])
stop_count = mmap_read_self(addr);
/* --------------------End Critical section-------------- */
- result = (stop_count-start_count)/1000;
+ pre_loop_res = abs(stop_count-start_count)/1000;
printf("\nsum=%d Avg count [ Loop + Read ] = %ld\n", sum,
- (stop_count-start_count)/1000);
+ pre_loop_res);
start_count = stop_count = 0;
/* --------------------Critical section-------------- */
start_count = mmap_read_self(addr);
@@ -179,10 +181,11 @@ int main(int ac, char *argv[])
stop_count = mmap_read_self(addr);
/* --------------------End Critical section-------------- */
+ post_loop_res = abs(stop_count-start_count)/1000;
printf("sum=%d Avg count [ Loop ] = %ld\n", sum,
- (stop_count-start_count)/1000);
+ post_loop_res);
printf("\n--------------------------------------------------------\n");
- printf("\tDelay[cpucycles]=%d", result-((stop_count-start_count)/1000));
+ printf("\tDelay[cpucycles]=%d\n", abs(post_loop_res - pre_loop_res));
printf("\n--------------------------------------------------------\n");
munmap(addr, page_size);
free(a);