Updated PCI IDs to latest snapshot.
[tangerine.git] / test / benchmarks / clib / memset.c
blob016954b49eebe8e14894eb1d9c8a3ce4346a8a45
1 /*
2 Copyright © 2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <sys/time.h>
7 #include <stdio.h>
8 #include <string.h>
10 #include <exec/types.h>
11 #include <exec/memory.h>
12 #include <proto/exec.h>
14 #define BUFFERSIZE (10*1024*1024) // 10 MB
15 #define FUNCTION memset
17 int main()
19 struct timeval tv_start,
20 tv_end;
21 APTR buffer = NULL;
22 UBYTE patterns[] = { 0x15, 0x25, 0x65, 0x42 };
23 int count = 300;
24 double elapsed = 0.0;
25 int i;
27 buffer = AllocVec(BUFFERSIZE, MEMF_ANY);
29 gettimeofday(&tv_start, NULL);
31 for(i = 0; i < count; i++)
33 FUNCTION(buffer, 0, BUFFERSIZE);
36 gettimeofday(&tv_end, NULL);
38 elapsed = ((double)(((tv_end.tv_sec * 1000000) + tv_end.tv_usec)
39 - ((tv_start.tv_sec * 1000000) + tv_start.tv_usec)))/1000000.;
41 printf
43 "Clearing memory\n"
44 "---------------\n"
45 "Elapsed time: %f seconds\n"
46 "Number of bytes: %f\n"
47 "Bytes per second: %f\n",
48 elapsed, (double) count * BUFFERSIZE,
49 (double) count * BUFFERSIZE / elapsed
52 gettimeofday(&tv_start, NULL);
54 for(i = 0; i < count; i++)
56 FUNCTION(buffer, patterns[i % sizeof(patterns)], BUFFERSIZE);
59 gettimeofday(&tv_end, NULL);
61 elapsed = ((double)(((tv_end.tv_sec * 1000000) + tv_end.tv_usec)
62 - ((tv_start.tv_sec * 1000000) + tv_start.tv_usec)))/1000000.;
64 printf
66 "Filling memory with pattern\n"
67 "---------------------------\n"
68 "Elapsed time: %f seconds\n"
69 "Number of bytes: %f\n"
70 "Bytes per second: %f\n",
71 elapsed, (double) count * BUFFERSIZE,
72 (double) count * BUFFERSIZE / elapsed
74 FreeVec(buffer);
76 return 0;