9 void test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes));
12 extern void docopy1(const void *s, void *d, size_t bytes);
13 extern void docopy2(const void *s, void *d, size_t bytes);
14 extern void docopy3(const void *s, void *d, size_t bytes);
15 extern void docopy4(const void *s, void *d, size_t bytes);
16 extern void docopy5(const void *s, void *d, size_t bytes);
17 extern void docopy6(const void *s, void *d, size_t bytes);
18 extern void docopy7(const void *s, void *d, size_t bytes);
19 extern void fpcleanup(void);
23 main(int ac, char **av)
30 fprintf(stderr, "%s bytes\n", av[0]);
34 bytes = strtol(av[1], &ptr, 0);
46 bytes *= 1024 * 1024 * 1024;
51 fprintf(stderr, "suffix '%s' not understood\n", ptr);
54 if (bytes <= 0 && (bytes & 127)) {
55 fprintf(stderr, "# of bytes must be a multiple of 128\n");
58 buf = mmap(NULL, bytes * 2, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
59 if (buf == MAP_FAILED) {
60 perror("mmap/buffer");
63 bzero(buf, bytes * 2);
65 test_using("bcopy", buf, bytes, bcopy);
67 test_using("docopy1", buf, bytes, docopy1);
68 test_using("docopy2", buf, bytes, docopy2);
69 test_using("docopy3", buf, bytes, docopy3);
70 test_using("docopy4", buf, bytes, docopy4);
71 test_using("docopy5", buf, bytes, docopy5);
72 test_using("docopy6", buf, bytes, docopy6);
73 test_using("docopy7", buf, bytes, docopy7);
79 test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes))
86 for (i = 0; (i & 31) || stop_timing(0, NULL) == 0; ++i) {
87 copyf(buf, buf + bytes, bytes);
92 for (i = loops - 1; i >= 0; --i) {
93 copyf(buf, buf + bytes, bytes);
98 stop_timing(loops, ctl);
100 printf("%s %d %5.2f MBytes/sec\n", ctl, bytes,
101 (double)loops * (double)bytes / (double)us);