summaryrefslogtreecommitdiff
path: root/perf_ev_open.c
diff options
context:
space:
mode:
Diffstat (limited to 'perf_ev_open.c')
-rw-r--r--perf_ev_open.c12
1 files changed, 7 insertions, 5 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);