diff options
Diffstat (limited to 'src/test/old')
-rw-r--r-- | src/test/old/test_disk_bw.cc | 62 | ||||
-rw-r--r-- | src/test/old/test_setlayout.c | 24 | ||||
-rw-r--r-- | src/test/old/testfilepath.cc | 22 |
3 files changed, 108 insertions, 0 deletions
diff --git a/src/test/old/test_disk_bw.cc b/src/test/old/test_disk_bw.cc new file mode 100644 index 000000000..d509a510d --- /dev/null +++ b/src/test/old/test_disk_bw.cc @@ -0,0 +1,62 @@ + +#include <sys/time.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <sys/uio.h> + +#include "common/Clock.h" +#include "common/safe_io.h" + +#include <iostream> +using namespace std; + +int main(int argc, char **argv) +{ + void *buf; + int fd, count, loop = 0; + + if (argc != 4) { + fprintf(stderr, "Usage: %s device bsize count\n", argv[0]); + exit (0); + } + + int bsize = atoi(argv[2]); + count = atoi(argv[3]); + + posix_memalign(&buf, sysconf(_SC_PAGESIZE), bsize); + + //if ((fd = open(argv[1], O_SYNC|O_RDWR)) < 0) { + if ((fd = open(argv[1], O_DIRECT|O_RDWR)) < 0) { + + fprintf(stderr, "Can't open device %s\n", argv[1]); + exit (4); + } + + + utime_t start = ceph_clock_now(); + while (loop++ < count) { + int ret = safe_write(fd, buf, bsize); + if (ret) + ceph_abort(); + //if ((loop % 100) == 0) + //fprintf(stderr, "."); + } + ::fsync(fd); + ::close(fd); + utime_t end = ceph_clock_now(); + end -= start; + + + char hostname[80]; + gethostname(hostname, 80); + + double mb = bsize*count/1024/1024; + + cout << hostname << "\t" << mb << " MB\t" << end << " seconds\t" << (mb / (double)end) << " MB/sec" << std::endl; +} diff --git a/src/test/old/test_setlayout.c b/src/test/old/test_setlayout.c new file mode 100644 index 000000000..d0ad8954e --- /dev/null +++ b/src/test/old/test_setlayout.c @@ -0,0 +1,24 @@ +#define __USE_GNU 1 +#include <fcntl.h> +#include <netinet/in.h> +#include <linux/types.h> +#include "include/ceph_fs.h" +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include "kernel/ioctl.h" + + +main() { + struct ceph_file_layout l; + int fd = open("foo.txt", O_RDONLY); + int r = ioctl(fd, CEPH_IOC_GET_LAYOUT, &l, sizeof(l)); + printf("get = %d\n", r); + + l.fl_stripe_unit = 65536; + l.fl_object_size = 65536; + + r = ioctl(fd, CEPH_IOC_SET_LAYOUT, &l, sizeof(l)); + printf("set = %d\n", r); +} diff --git a/src/test/old/testfilepath.cc b/src/test/old/testfilepath.cc new file mode 100644 index 000000000..78ecc197f --- /dev/null +++ b/src/test/old/testfilepath.cc @@ -0,0 +1,22 @@ + +#include "include/filepath.h" +#include <iostream> +using namespace std; + +int print(const string &s) { + filepath fp = s; + cout << "s = " << s << " filepath = " << fp << endl; + cout << " depth " << fp.depth() << endl; + for (int i=0; i<fp.depth(); i++) { + cout << "\t" << i << " " << fp[i] << endl; + } +} + +int main() { + filepath p; + print("/home/sage"); + print("a/b/c"); + print("/a/b/c"); + print("/a/b/c/"); + print("/a/b/../d"); +} |