From 6a30da2306c56c1e84f37addd8d9084d0a51661f Mon Sep 17 00:00:00 2001 From: sageweil Date: Sun, 16 Sep 2007 22:40:47 +0000 Subject: [PATCH] added test_disk_bw git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1846 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/Makefile | 8 ++++- trunk/ceph/test/test_disk_bw.cc | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 trunk/ceph/test/test_disk_bw.cc diff --git a/trunk/ceph/Makefile b/trunk/ceph/Makefile index 70c62b685119d..2f664db478747 100644 --- a/trunk/ceph/Makefile +++ b/trunk/ceph/Makefile @@ -139,6 +139,9 @@ test: depend ${TEST_TARGETS} mkmonmap: mkmonmap.cc common.o ${CC} ${CFLAGS} ${LIBS} $^ -o $@ +extractosdmaps: extractosdmaps.cc common.o osd.o mon.o ebofs.o + ${CC} ${CFLAGS} ${LIBS} $^ -o $@ + cmon: cmon.cc mon.o msg/SimpleMessenger.o common.o ${CC} ${CFLAGS} ${LIBS} $^ -o $@ @@ -234,6 +237,9 @@ testos: test/testos.o ebofs.o osbdb.o common.o gprof-helper.so: test/gprof-helper.c gcc -shared -fPIC test/gprof-helper.c -o gprof-helper.so -lpthread -ldl +test_disk_bw: test/test_disk_bw.cc common.o + ${CC} ${CFLAGS} ${LIBS} $^ -o $@ + # bits common.o: ${COMMON_OBJS} ${LDINC} $@ $^ @@ -288,7 +294,7 @@ TAGS: depend: $(RM) .depend makedepend -f- -- $(CFLAGS) -- $(SRCS) > .depend 2>/dev/null -# for f in $(SRCS) ; do cpp -MM $(CFLAGS) $$f >> .depend ; done +# for f in $(SRCS) ; do cpp -MM $(CFLAGS) $$f 2> /dev/null >> .depend ; done # now add a line to include the dependency list. diff --git a/trunk/ceph/test/test_disk_bw.cc b/trunk/ceph/test/test_disk_bw.cc new file mode 100644 index 0000000000000..d1f44af3127ca --- /dev/null +++ b/trunk/ceph/test/test_disk_bw.cc @@ -0,0 +1,52 @@ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "common/Clock.h" + +#include +using namespace std; + +int main(int argc, char **argv) +{ + void *buf; + int dev_id, count, loop = 0, ret; + + if (argc != 3) { + fprintf(stderr, "Usage: %s device mb\n", argv[0]); + exit (0); + } + + count = atoi(argv[2]); + int bsize = 1048576; + + posix_memalign(&buf, sysconf(_SC_PAGESIZE), bsize); + + if ((dev_id = open(argv[1], O_DIRECT|O_RDWR)) < 0) { + fprintf(stderr, "Can't open device %s\n", argv[1]); + exit (4); + } + + fprintf(stderr, "device is %s, dev_id is %d\n", argv[1], dev_id); + + utime_t start = g_clock.now(); + while (loop++ < count) { + ret = ::write(dev_id, buf, bsize); + if ((loop % 100) == 0) + fprintf(stderr, "."); + } + utime_t end = g_clock.now(); + end -= start; + + int mb = count; + + cout << mb << " MB, " << end << " seconds, " << ((double)mb / (double)end) << " MB/sec" << std::endl; +} -- 2.39.5