aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-05-15 10:25:25 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-05-15 10:31:55 +0300
commit1a7011f6c87d55b42803edcbefb1d2fbe583a13a (patch)
treede46743d5801380c018072c14a11fbbae1ccd46e
parentbea332d5831193aaf7f5428956edc8e437fde214 (diff)
Add benchmark_just_do_work.py for external benchmarking
-rw-r--r--.gitignore1
-rw-r--r--benchmark_just_do_work.py31
2 files changed, 32 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 755398c..da388d1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ dist/
*.egg-info/
__pycache__
.envrc
+data/
diff --git a/benchmark_just_do_work.py b/benchmark_just_do_work.py
new file mode 100644
index 0000000..b9a7696
--- /dev/null
+++ b/benchmark_just_do_work.py
@@ -0,0 +1,31 @@
+# A script that does some work. Useful for external benchmarking tools, e.g. hyperfine.
+# Compare two commits like this:
+#
+# hyperfine --warmup 1 \
+# --command-name no_sync --prepare 'git checkout c8d45e8 && (rm -r data || true)' 'python3 benchmark_just_do_work.py data' \
+# --command-name sync --prepare 'git checkout b6c1a44 && (rm -r data || true)' 'python3 benchmark_just_do_work.py data' \
+# --cleanup 'rm -r data'
+
+import argparse
+from femtoqueue import FemtoQueue
+
+def benchmark_femtoqueue(data_dir: str, num_tasks: int = 1000):
+ queue = FemtoQueue(data_dir=data_dir, node_id="node1")
+
+ data = b"x" * 100 # 100-byte payload
+
+ for _ in range(num_tasks):
+ queue.push(data)
+
+ while True:
+ task = queue.pop()
+ if not task:
+ break
+ queue.done(task)
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="FemtoQueue: Just run some tasks for external benchmarking")
+ parser.add_argument("data_dir", type=str, help="Data directory. Won't be cleaned up!")
+ args = parser.parse_args()
+
+ benchmark_femtoqueue(args.data_dir)