4 * $DragonFly: src/test/sysperf/memcpy.c,v 1.1 2004/04/29 18: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
));
13 extern void docopy1(const void *s
, void *d
, size_t bytes
);
14 extern void docopy2(const void *s
, void *d
, size_t bytes
);
15 extern void docopy3(const void *s
, void *d
, size_t bytes
);
16 extern void docopy4(const void *s
, void *d
, size_t bytes
);
17 extern void docopy5(const void *s
, void *d
, size_t bytes
);
18 extern void docopy6(const void *s
, void *d
, size_t bytes
);
19 extern void docopy7(const void *s
, void *d
, size_t bytes
);
20 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");
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
);
66 test_using("docopy1", buf
, bytes
, docopy1
);
67 test_using("docopy2", buf
, bytes
, docopy2
);
68 test_using("docopy3", buf
, bytes
, docopy3
);
69 test_using("docopy4", buf
, bytes
, docopy4
);
70 test_using("docopy5", buf
, bytes
, docopy5
);
71 test_using("docopy6", buf
, bytes
, docopy6
);
72 test_using("docopy7", buf
, bytes
, docopy7
);
77 test_using(const char *ctl
, char *buf
, int bytes
, void (*copyf
)(const void *s1
, void *d
, size_t bytes
))
84 for (i
= 0; (i
& 31) || stop_timing(0, NULL
) == 0; ++i
) {
85 copyf(buf
, buf
+ bytes
, bytes
);
90 for (i
= loops
- 1; i
>= 0; --i
) {
91 copyf(buf
, buf
+ bytes
, bytes
);
94 stop_timing(loops
, ctl
);
96 printf("%s %d %5.2f MBytes/sec\n", ctl
, bytes
,
97 (double)loops
* (double)bytes
/ (double)us
);