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);
40
for (int i=0; i<count; i++) {
41
off64_t so, o = (lrand48() % numblocks) * 4096;
42
//cout << "s = " << s << " o = " << o << endl;
43
//::lseek(fd, o, SEEK_SET);
44
lseek64(fd, o, SEEK_SET);
45
int r = ::read(fd, buf, 4096);
46
//int r = ::read(fd, buf, s);
47
if (r < 0) cout << "r = " << r << " " << strerror(errno) << endl;
49
int range = 1000000/4096;
50
so = o + 4096*((rand() % range) );//- range/2);
51
//cout << o << " " << so << " " << (so-o) << endl;
53
utime_t start = ceph_clock_now(g_ceph_context);
54
lseek64(fd, so, SEEK_SET);
55
r = ::read(fd, buf, blocks*4096);
56
utime_t end = ceph_clock_now(g_ceph_context);
57
timeper += (end-start);
61
cout << blocks << "\t" << s << "\t" << (double)timeper << endl;