summaryrefslogtreecommitdiffstats
path: root/src/test/librados/completion_speed.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/librados/completion_speed.cc')
-rw-r--r--src/test/librados/completion_speed.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/librados/completion_speed.cc b/src/test/librados/completion_speed.cc
new file mode 100644
index 000000000..708a58425
--- /dev/null
+++ b/src/test/librados/completion_speed.cc
@@ -0,0 +1,38 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/rados/librados.hpp"
+#include "common/ceph_context.h"
+#include "common/Finisher.h"
+#include "librados/AioCompletionImpl.h"
+
+
+constexpr int max_completions = 10'000'000;
+int completed = 0;
+auto cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get();
+Finisher f(cct);
+
+void completion_cb(librados::completion_t cb, void* arg) {
+ auto c = static_cast<librados::AioCompletion*>(arg);
+ delete c;
+ if (++completed < max_completions) {
+ auto aio = librados::Rados::aio_create_completion();
+ aio->set_complete_callback(static_cast<void*>(aio), &completion_cb);
+ f.queue(new librados::C_AioComplete(aio->pc));
+ }
+}
+
+int main(void) {
+ auto aio = librados::Rados::aio_create_completion();
+ aio->set_complete_callback(static_cast<void*>(aio), &completion_cb);
+ f.queue(new librados::C_AioComplete(aio->pc));
+ f.start();
+
+ while (completed < max_completions)
+ f.wait_for_empty();
+
+ f.stop();
+
+ assert(completed == max_completions);
+ cct->put();
+}