9 void test_using(const char *ctl, char *buf, int bytes, void (*zerof)(void *d, size_t bytes));
11 extern void dozero1(void *d, size_t bytes);
12 extern void dozero2(void *d, size_t bytes);
13 extern void dozero3(void *d, size_t bytes);
14 extern void dozero4(void *d, size_t bytes);
15 extern void dozero5(void *d, size_t bytes);
16 extern void dozero6(void *d, size_t bytes);
17 extern void dozero7(void *d, size_t bytes);
18 extern void fpcleanup(void);
21 main(int ac, char **av)
28 fprintf(stderr, "%s bytes\n", av[0]);
32 bytes = strtol(av[1], &ptr, 0);
44 bytes *= 1024 * 1024 * 1024;
49 fprintf(stderr, "suffix '%s' not understood\n", ptr);
52 if (bytes <= 0 && (bytes & 127)) {
53 fprintf(stderr, "# of bytes must be a multiple of 128\n");
57 buf = mmap(NULL, bytes * 2, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
58 if (buf == MAP_FAILED) {
59 perror("mmap/buffer");
62 bzero(buf, bytes * 2);
64 test_using("bzero", buf, bytes, (void *)bzero);
66 test_using("dozero1", buf, bytes, dozero1);
67 test_using("dozero2", buf, bytes, dozero2);
68 test_using("dozero3", buf, bytes, dozero3);
69 test_using("dozero4", buf, bytes, dozero4);
70 test_using("dozero5", buf, bytes, dozero5);
71 test_using("dozero6", buf, bytes, dozero6);
72 test_using("dozero7", buf, bytes, dozero7);
78 test_using(const char *ctl, char *buf, int bytes, void (*zerof)(void *d, size_t bytes))
85 for (i = 0; (i & 31) || stop_timing(0, NULL) == 0; ++i) {
91 for (i = loops - 1; i >= 0; --i) {
97 stop_timing(loops, ctl);
99 printf("%s %d %5.2f MBytes/sec\n", ctl, bytes,
100 (double)loops * (double)bytes / (double)us);