blob: 348c8dde5c6af6511555787bf30501e20c33dfe4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include <unistd.h>
#include <map>
#include <errno.h>
#include "include/utime.h"
#include "common/Clock.h"
#include "common/errno.h"
using namespace std;
int main(int argc, const char **argv)
{
const char *fn = argv[1];
multimap<utime_t, utime_t> latency;
unsigned max = 10;
int fd = ::open(fn, O_CREAT|O_RDWR, 0644);
if (fd < 1) {
int err = errno;
cerr << "failed to open " << fn << " with " << cpp_strerror(err) << std::endl;
return -1;
}
while (true) {
utime_t now = ceph_clock_now();
int r = ::pwrite(fd, fn, strlen(fn), 0);
ceph_assert(r >= 0);
utime_t lat = ceph_clock_now();
lat -= now;
utime_t oldmin;
if (!latency.empty())
oldmin = latency.begin()->first;
latency.insert(make_pair(lat, now));
utime_t newmin = latency.begin()->first;
while (latency.size() > max)
latency.erase(latency.begin());
if (oldmin == newmin) {
cout << "latency\tat" << std::endl;
for (multimap<utime_t,utime_t>::reverse_iterator p = latency.rbegin();
p != latency.rend();
++p) {
cout << p->first << "\t" << p->second << std::endl;
}
}
}
}
|