comparison TOOLS/fastmemcpybench.c @ 562:312fee2a6816

Initial release, used to benchmark fastmemcpy.h code from libvo.
author atmosfear
date Sat, 21 Apr 2001 18:19:12 +0000
parents
children 9935c60a15a0
comparison
equal deleted inserted replaced
561:36fd71db0d33 562:312fee2a6816
1 /*
2 fastmemcpybench.c used to benchmark fastmemcpy.h code from libvo.
3
4 Note: this code can not be used on PentMMX-PII because they contain
5 a bug in rdtsc. For Intel processors since P6(PII) rdpmc should be used
6 instead. For PIII it's disputable and seems bug was fixed but I don't
7 tested it.
8 */
9
10 #include <stdio.h>
11
12 #include "../libvo/fastmemcpy.h"
13
14 #define ARR_SIZE 100000
15 //#define ARR_SIZE 1000000
16
17 static inline unsigned long long int read_tsc( void )
18 {
19 unsigned long long int retval;
20 __asm __volatile ("rdtsc":"=A"(retval)::"memory");
21 return retval;
22 }
23
24 unsigned char arr1[ARR_SIZE],arr2[ARR_SIZE];
25
26 int main( void )
27 {
28 unsigned long long int v1,v2;
29 unsigned char * marr1,*marr2;
30 marr1 = &arr1[1];
31 marr2 = &arr2[3];
32 v1 = read_tsc();
33 memcpy(marr1,marr2,ARR_SIZE-4);
34 v2 = read_tsc();
35 printf("v1 = %llu v2 = %llu v2-v1=%llu\n",v1,v2,v2-v1);
36 return 0;
37 }