OpenCores
URL https://opencores.org/ocsvn/bluespec_md6/bluespec_md6/trunk

Subversion Repositories bluespec_md6

[/] [bluespec_md6/] [trunk/] [C_implementation/] [testmemcpy.c] - Blame information for rev 7

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 kfleming
/* testmemcpy.c
2
** Ronald L. Rivest
3
** 5/12/08
4
**
5
** Routine to test speed of memcpy vs just a loop, for
6
** various size blocks to move.
7
**
8
** The cutoff for 32-bit compilation onto my laptop gives
9
** a cutoff of about blocksize = 16; below that the loop
10
** is faster; above that memcpy is faster.
11
*/
12
 
13
#include <stdio.h>
14
#include <stdint.h>
15
#include <time.h>
16
 
17
typedef uint64_t md6_word;
18
 
19
md6_word A[8092];
20
md6_word B[8092];
21
 
22
int main()
23
{ int blocksize;
24
  time_t start_time, end_time;
25
  int i,j;
26
  int ntrials = 1000000000;
27
  printf("ntrials = %d\n",ntrials);
28
  for (blocksize = 1; blocksize<= 128; blocksize += blocksize)
29
    {
30
      printf("Blocksize = %d 64-bit words\n",blocksize);
31
 
32
      time(&start_time);
33
      for (i=0;i<ntrials;i++)
34
        memcpy(A,B,blocksize*sizeof(md6_word));
35
      time(&end_time);
36
      printf("  memcpy: %ld seconds.\n",(long)end_time-start_time);
37
 
38
      time(&start_time);
39
      for (i=0;i<ntrials;i++)
40
        for (j=0;j<blocksize;j++)
41
          A[j] = B[j];
42
      time(&end_time);
43
      printf("  loop: %ld seconds.\n",(long)end_time-start_time);
44
    }
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.