4 * $DragonFly: src/test/sysperf/memcpy.c,v 1.1 2004/04/29 16:14:53 dillon Exp $
11 void test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes));
14 extern void docopy1(const void *s, void *d, size_t bytes);
15 extern void docopy2(const void *s, void *d, size_t bytes);
16 extern void docopy3(const void *s, void *d, size_t bytes);
17 extern void docopy4(const void *s, void *d, size_t bytes);
18 extern void docopy5(const void *s, void *d, size_t bytes);
19 extern void docopy6(const void *s, void *d, size_t bytes);
20 extern void docopy7(const void *s, void *d, size_t bytes);
21 extern void fpcleanup(void);
25 main(int ac, char **av)
32 fprintf(stderr, "%s bytes\n", av[0]);
36 bytes = strtol(av[1], &ptr, 0);
48 bytes *= 1024 * 1024 * 1024;
53 fprintf(stderr, "suffix '%s' not understood\n");
56 if (bytes <= 0 && (bytes & 127)) {
57 fprintf(stderr, "# of bytes must be a multiple of 128\n");
60 buf = mmap(NULL, bytes * 2, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0);
61 if (buf == MAP_FAILED) {
62 perror("mmap/buffer");
65 bzero(buf, bytes * 2);
67 test_using("bcopy", buf, bytes, bcopy);
69 test_using("docopy1", buf, bytes, docopy1);
70 test_using("docopy2", buf, bytes, docopy2);
71 test_using("docopy3", buf, bytes, docopy3);
72 test_using("docopy4", buf, bytes, docopy4);
73 test_using("docopy5", buf, bytes, docopy5);
74 test_using("docopy6", buf, bytes, docopy6);
75 test_using("docopy7", buf, bytes, docopy7);
81 test_using(const char *ctl, char *buf, int bytes, void (*copyf)(const void *s1, void *d, size_t bytes))
88 for (i = 0; (i & 31) || stop_timing(0, NULL) == 0; ++i) {
89 copyf(buf, buf + bytes, bytes);
94 for (i = loops - 1; i >= 0; --i) {
95 copyf(buf, buf + bytes, bytes);
100 stop_timing(loops, ctl);
102 printf("%s %d %5.2f MBytes/sec\n", ctl, bytes,
103 (double)loops * (double)bytes / (double)us);