ram_bandwidth_overhead.c
831 Bytes
#include <stdio.h>
#include <stdlib.h>
#define KB 1024
#define MB 1024*KB
#define SIZE 10000000
int arr[SIZE] = {1, 2, 3, 4, 56};
void main()
{
unsigned time1, time2, sum=0;
struct timeval start, end;
int i;
int temp, temp2, temp3, temp4;
//asm volatile("mrc p15, 0, %0, c9, c14, 0" : "=r" (i));
//asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time1));
gettimeofday(&start, NULL);
for (i = 0; i < SIZE/4; i=i+8) {
temp = i;
temp2 = i+(SIZE/4);
temp3 = i+(SIZE/2);
temp4 = i+(3*SIZE/4);
}
gettimeofday(&end, NULL);
//asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r" (time2));
//printf("%u", time2-time1);
printf("Start %llu.%llu\n",start.tv_sec*1e6, start.tv_usec);
printf("End %llu.%llu\n",end.tv_sec*1e6, end.tv_usec);
printf("%llu\n",(-start.tv_sec*1e6-start.tv_usec+end.tv_sec*1e6+end.tv_usec));
}