[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] another compiler oddity
I wrote
>
> A cosmetically modified version of your test program (see attached)
> gives me this result:
oops sorry - here's the file.
John
#include <stdio.h>
#include <sys/time.h>
#include <sys/times.h>
#define BRAM_START 0x00001000
#define BRAM_SIZE 0x00001000
#define NR_TEST 100000
volatile unsigned char dram[BRAM_SIZE];
volatile unsigned char *bram=(unsigned char *)BRAM_START;
struct timeval start, stop;
void print_time(void)
{
time_t sec;
suseconds_t usec;
sec = stop.tv_sec - start.tv_sec;
usec = stop.tv_usec - start.tv_usec;
if(usec < 0){
usec += 1000000;
sec--;
}
printf("Elapsed time : %ld.%ld\n", sec, usec);
}
static void do_test(volatile unsigned char *addr)
{
int i,j;
gettimeofday(&start, NULL);
for (i=0; i<NR_TEST; i++)
*(addr) = i;
gettimeofday(&stop, NULL);
print_time();
}
static inline void do_test_inline(volatile unsigned char *addr)
{
int i,j;
gettimeofday(&start, NULL);
for (i=0; i<NR_TEST; i++)
*(addr) = i;
gettimeofday(&stop, NULL);
print_time();
}
int main(void)
{
printf("DRAM test\n");
printf("do_test_inline():\n");
do_test(dram);
printf("do_test():\n");
do_test_inline(dram);
printf("\n\nBRAM test\n");
printf("do_test_inline():\n");
do_test_inline(bram);
printf("do_test()\n");
do_test(bram);
return 0;
}