From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/test/osd/TestOpStat.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/test/osd/TestOpStat.h (limited to 'src/test/osd/TestOpStat.h') diff --git a/src/test/osd/TestOpStat.h b/src/test/osd/TestOpStat.h new file mode 100644 index 000000000..a279287fd --- /dev/null +++ b/src/test/osd/TestOpStat.h @@ -0,0 +1,53 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +#include "common/ceph_mutex.h" +#include "common/Cond.h" +#include "include/rados/librados.hpp" + +#ifndef TESTOPSTAT_H +#define TESTOPSTAT_H + +class TestOp; + +class TestOpStat { +public: + mutable ceph::mutex stat_lock = ceph::make_mutex("TestOpStat lock"); + + TestOpStat() = default; + + static uint64_t gettime() + { + timeval t; + gettimeofday(&t,0); + return (1000000*t.tv_sec) + t.tv_usec; + } + + class TypeStatus { + public: + map inflight; + multiset latencies; + void begin(TestOp *in) + { + ceph_assert(!inflight.count(in)); + inflight[in] = gettime(); + } + + void end(TestOp *in) + { + ceph_assert(inflight.count(in)); + uint64_t curtime = gettime(); + latencies.insert(curtime - inflight[in]); + inflight.erase(in); + } + + void export_latencies(map &in) const; + }; + map stats; + + void begin(TestOp *in); + void end(TestOp *in); + friend std::ostream & operator<<(std::ostream &, const TestOpStat &); +}; + +std::ostream & operator<<(std::ostream &out, const TestOpStat &rhs); + +#endif -- cgit v1.2.3