]> git.proxmox.com Git - ceph.git/blob - ceph/src/test/bench/detailed_stat_collector.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / test / bench / detailed_stat_collector.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2
3 #ifndef DETAILEDSTATCOLLECTERH
4 #define DETAILEDSTATCOLLECTERH
5
6 #include "stat_collector.h"
7 #include "common/Formatter.h"
8 #include <boost/scoped_ptr.hpp>
9 #include "common/Mutex.h"
10 #include "common/Cond.h"
11 #include "include/utime.h"
12 #include <list>
13 #include <map>
14 #include <boost/tuple/tuple.hpp>
15 #include <ostream>
16
17 class DetailedStatCollector : public StatCollector {
18 public:
19 class AdditionalPrinting {
20 public:
21 virtual void operator()(std::ostream *) = 0;
22 virtual ~AdditionalPrinting() {}
23 };
24 private:
25 struct Op {
26 string type;
27 utime_t start;
28 double latency;
29 uint64_t size;
30 uint64_t seq;
31 Op(
32 string type,
33 utime_t start,
34 double latency,
35 uint64_t size,
36 uint64_t seq)
37 : type(type), start(start), latency(latency),
38 size(size), seq(seq) {}
39 void dump(ostream *out, Formatter *f);
40 };
41 class Aggregator {
42 uint64_t recent_size;
43 uint64_t total_size;
44 double recent_latency;
45 double total_latency;
46 utime_t last;
47 utime_t first;
48 uint64_t recent_ops;
49 uint64_t total_ops;
50 bool started;
51 public:
52 Aggregator();
53
54 void add(const Op &op);
55 void dump(Formatter *f);
56 };
57 const double bin_size;
58 boost::scoped_ptr<Formatter> f;
59 ostream *out;
60 ostream *summary_out;
61 boost::scoped_ptr<AdditionalPrinting> details;
62 utime_t last_dump;
63
64 Mutex lock;
65 Cond cond;
66
67 map<string, Aggregator> aggregators;
68
69 map<uint64_t, pair<uint64_t, utime_t> > not_applied;
70 map<uint64_t, pair<uint64_t, utime_t> > not_committed;
71 map<uint64_t, pair<uint64_t, utime_t> > not_read;
72
73 uint64_t cur_seq;
74
75 void dump(
76 const string &type,
77 boost::tuple<utime_t, utime_t, uint64_t, uint64_t> stuff);
78 public:
79 DetailedStatCollector(
80 double bin_size,
81 Formatter *formatter,
82 ostream *out,
83 ostream *summary_out,
84 AdditionalPrinting *details = 0
85 );
86
87 uint64_t next_seq() override;
88 void start_write(uint64_t seq, uint64_t size) override;
89 void start_read(uint64_t seq, uint64_t size) override;
90 void write_applied(uint64_t seq) override;
91 void write_committed(uint64_t seq) override;
92 void read_complete(uint64_t seq) override;
93
94 };
95
96 #endif