aboutsummaryrefslogtreecommitdiffstats
path: root/benchmark.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-05-14 12:25:52 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-05-14 12:25:52 +0300
commit4b42039d22008dd65a1bb176d1b80e167b4d76a2 (patch)
treecc7ac8af3ee3e49836724feb496c8382c7b48e56 /benchmark.py
parent7fdc3a0403fb542616fca1626657eb826ac5b2f6 (diff)
Add and improve benchmark scripts
Diffstat (limited to 'benchmark.py')
-rw-r--r--benchmark.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/benchmark.py b/benchmark.py
deleted file mode 100644
index 7a7df24..0000000
--- a/benchmark.py
+++ /dev/null
@@ -1,34 +0,0 @@
-import time
-import tempfile
-import shutil
-from femtoqueue import FemtoQueue, FemtoTask
-
-def benchmark_femtoqueue(num_tasks: int = 1000):
- tmpdir = tempfile.mkdtemp()
- queue = FemtoQueue(data_dir=tmpdir, node_name="node1")
-
- data = b"x" * 100 # 100-byte payload
-
- print(f"Pushing {num_tasks} tasks...")
- start = time.time()
- for _ in range(num_tasks):
- queue.push(data)
- push_duration = time.time() - start
- print(f"Pushed in {push_duration:.4f}s ({num_tasks / push_duration:.2f} tasks/sec)")
-
- print("Processing tasks (pop + done)...")
- start = time.time()
- processed = 0
- while True:
- task = queue.pop()
- if not task:
- break
- queue.done(task)
- processed += 1
- process_duration = time.time() - start
- print(f"Processed in {process_duration:.4f}s ({processed / process_duration:.2f} tasks/sec)")
-
- shutil.rmtree(tmpdir)
-
-if __name__ == "__main__":
- benchmark_femtoqueue(1000)