#include <stdio.h>
#include <sys/time.h>

#define TRANSFER_SIZE  (1024 * 1024)
#define COUNT          20

unsigned char src_buf[TRANSFER_SIZE];
unsigned char dst_buf[TRANSFER_SIZE];

void mymemcpy(unsigned int* dst, unsigned int* src, int count){
  int i;
  count >>= 2;
  for(count --; count != 0;){
    dst[count--] = src[count];
  }
}

int main(){
  struct timeval tv;
  struct timezone tz;
  struct timeval tv_e;
  struct timezone tz_e;
  int i;

  gettimeofday(&tv, &tz);
  for(i = 0; i < COUNT; i++){
    memcpy(dst_buf, src_buf,  TRANSFER_SIZE);
    // memset(dst_buf, 1,  TRANSFER_SIZE);
    // mymemcpy(dst_buf, src_buf,  TRANSFER_SIZE);
  }
  gettimeofday(&tv_e, &tz_e);

  printf("Rate: %.2fMB/s\n",
	 (TRANSFER_SIZE * COUNT / (1024 * 1024.0)) /
	 ((tv_e.tv_sec - tv.tv_sec) + (tv_e.tv_usec - tv.tv_usec) / 1000000.0) );
  return 0;
}