]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/mon: add commit benchmark script
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 14 Jul 2023 20:56:01 +0000 (16:56 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Fri, 21 Jul 2023 14:09:04 +0000 (10:09 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/test/mon/bench_commit.py [new file with mode: 0755]

diff --git a/src/test/mon/bench_commit.py b/src/test/mon/bench_commit.py
new file mode 100755 (executable)
index 0000000..040bbef
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/python3
+
+import json
+import rados
+from statistics import mean, stdev
+import time
+
+times = []
+
+conf = {
+  'mon_client_target_rank': '0'
+}
+
+with rados.Rados(conffile=rados.Rados.DEFAULT_CONF_FILES, conf=conf) as conn:
+    for i in range(1000):
+        cmd = {
+            'prefix': 'config-key set',
+            'key': 'bench',
+            'val': str(i),
+        }
+        start = time.monotonic()
+        ret, buf, out = conn.mon_command(json.dumps(cmd), b'')
+        stop = time.monotonic()
+        assert ret == 0
+        times.append(stop-start)
+
+print(f"min/max/mean/stddev: {min(times):.6f}/{max(times):.6f}/{mean(times):.6f}/{stdev(times):.6f}")