X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Fbench%2Fdetailed_stat_collector.h;fp=src%2Fceph%2Fsrc%2Ftest%2Fbench%2Fdetailed_stat_collector.h;h=ad622f91a6c791a8dbe98844486672cf5e056177;hb=812ff6ca9fcd3e629e49d4328905f33eee8ca3f5;hp=0000000000000000000000000000000000000000;hpb=15280273faafb77777eab341909a3f495cf248d9;p=stor4nfv.git diff --git a/src/ceph/src/test/bench/detailed_stat_collector.h b/src/ceph/src/test/bench/detailed_stat_collector.h new file mode 100644 index 0000000..ad622f9 --- /dev/null +++ b/src/ceph/src/test/bench/detailed_stat_collector.h @@ -0,0 +1,96 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- + +#ifndef DETAILEDSTATCOLLECTERH +#define DETAILEDSTATCOLLECTERH + +#include "stat_collector.h" +#include "common/Formatter.h" +#include +#include "common/Mutex.h" +#include "common/Cond.h" +#include "include/utime.h" +#include +#include +#include +#include + +class DetailedStatCollector : public StatCollector { +public: + class AdditionalPrinting { + public: + virtual void operator()(std::ostream *) = 0; + virtual ~AdditionalPrinting() {} + }; +private: + struct Op { + string type; + utime_t start; + double latency; + uint64_t size; + uint64_t seq; + Op( + string type, + utime_t start, + double latency, + uint64_t size, + uint64_t seq) + : type(type), start(start), latency(latency), + size(size), seq(seq) {} + void dump(ostream *out, Formatter *f); + }; + class Aggregator { + uint64_t recent_size; + uint64_t total_size; + double recent_latency; + double total_latency; + utime_t last; + utime_t first; + uint64_t recent_ops; + uint64_t total_ops; + bool started; + public: + Aggregator(); + + void add(const Op &op); + void dump(Formatter *f); + }; + const double bin_size; + boost::scoped_ptr f; + ostream *out; + ostream *summary_out; + boost::scoped_ptr details; + utime_t last_dump; + + Mutex lock; + Cond cond; + + map aggregators; + + map > not_applied; + map > not_committed; + map > not_read; + + uint64_t cur_seq; + + void dump( + const string &type, + boost::tuple stuff); +public: + DetailedStatCollector( + double bin_size, + Formatter *formatter, + ostream *out, + ostream *summary_out, + AdditionalPrinting *details = 0 + ); + + uint64_t next_seq() override; + void start_write(uint64_t seq, uint64_t size) override; + void start_read(uint64_t seq, uint64_t size) override; + void write_applied(uint64_t seq) override; + void write_committed(uint64_t seq) override; + void read_complete(uint64_t seq) override; + +}; + +#endif