summaryrefslogtreecommitdiffstats
path: root/src/test/osd/TestOpStat.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/test/osd/TestOpStat.cc
parentInitial commit. (diff)
downloadceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz
ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/osd/TestOpStat.cc')
-rw-r--r--src/test/osd/TestOpStat.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/test/osd/TestOpStat.cc b/src/test/osd/TestOpStat.cc
new file mode 100644
index 000000000..eb13e1d55
--- /dev/null
+++ b/src/test/osd/TestOpStat.cc
@@ -0,0 +1,58 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+#include "include/interval_set.h"
+#include "include/buffer.h"
+#include <list>
+#include <map>
+#include <set>
+#include "RadosModel.h"
+#include "TestOpStat.h"
+
+void TestOpStat::begin(TestOp *in) {
+ std::lock_guard l{stat_lock};
+ stats[in->getType()].begin(in);
+}
+
+void TestOpStat::end(TestOp *in) {
+ std::lock_guard l{stat_lock};
+ stats[in->getType()].end(in);
+}
+
+void TestOpStat::TypeStatus::export_latencies(std::map<double,uint64_t> &in) const
+{
+ auto i = in.begin();
+ auto j = latencies.begin();
+ int count = 0;
+ while (j != latencies.end() && i != in.end()) {
+ count++;
+ if ((((double)count)/((double)latencies.size())) * 100 >= i->first) {
+ i->second = *j;
+ ++i;
+ }
+ ++j;
+ }
+}
+
+std::ostream & operator<<(std::ostream &out, const TestOpStat &rhs)
+{
+ std::lock_guard l{rhs.stat_lock};
+ for (auto i = rhs.stats.begin();
+ i != rhs.stats.end();
+ ++i) {
+ std::map<double,uint64_t> latency;
+ latency[10] = 0;
+ latency[50] = 0;
+ latency[90] = 0;
+ latency[99] = 0;
+ i->second.export_latencies(latency);
+
+ out << i->first << " latency: " << std::endl;
+ for (auto j = latency.begin();
+ j != latency.end();
+ ++j) {
+ if (j->second == 0) break;
+ out << "\t" << j->first << "th percentile: "
+ << j->second / 1000 << "ms" << std::endl;
+ }
+ }
+ return out;
+}