1 #include "include/types.h"
2 #include "common/Clock.h"
13 int main(int argc, char **argv)
17 int fd = ::open(fn, O_RDWR|O_DIRECT);//|O_SYNC|O_DIRECT);
21 int r = ioctl(fd, BLKGETSIZE64, &bytes);
22 uint64_t numblocks = bytes / 4096;
24 //uint64_t numblocks = atoll(argv[2]) * 4;// / 4096;
27 cout << "fn " << fn << endl;
28 cout << "numblocks " << numblocks << endl;
31 while (blocks <= 1024) {
32 //cout << "fd is " << fd << endl;
35 ::posix_memalign(&buf, 4096, 4096*blocks);
39 utime_t start = ceph_clock_now();
40 for (int i=0; i<count; i++) {
41 off64_t o = (lrand48() % numblocks) * 4096;
42 //cout << "s = " << s << " o = " << o << endl;
43 //::lseek(fd, o, SEEK_SET);
44 lseek64(fd, o, SEEK_SET);
46 int r = ::read(fd, buf, blocks*4096);
47 //int r = ::read(fd, buf, s);
48 if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
50 utime_t end = ceph_clock_now();
52 double timeper = end - start;
54 cout << blocks << "\t" << s << "\t" << (double)timeper << endl;