From 4b42039d22008dd65a1bb176d1b80e167b4d76a2 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Wed, 14 May 2025 12:25:52 +0300 Subject: Add and improve benchmark scripts --- benchmark.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 benchmark.py (limited to 'benchmark.py') 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) -- cgit v1.3