aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-05-22 13:04:08 +0300
committerJan Tuomi <jan@jantuomi.fi>2025-05-22 13:04:08 +0300
commit43dd3843f36b58d61fcfb6ca5ccffdc46118fd9c (patch)
treeb26ea3cdb6882a991bae99db345b65b52f9bdd90
parent201ab19b0204e8f7b9d7f1c4e95cd9a9ae7382d6 (diff)
Monotonicize benchmarks
-rw-r--r--benchmark_mini.py6
-rw-r--r--benchmark_throughput.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/benchmark_mini.py b/benchmark_mini.py
index c7ed63a..78df45e 100644
--- a/benchmark_mini.py
+++ b/benchmark_mini.py
@@ -11,10 +11,10 @@ def benchmark_femtoqueue(num_tasks: int = 1000):
data = b"x" * 100 # 100-byte payload
print(f"Pushing {num_tasks} tasks...")
- start = time.time()
+ start = time.monotonic()
for _ in range(num_tasks):
queue.push(data)
- push_duration = time.time() - start
+ push_duration = time.monotonic() - start
print(f"Pushed in {push_duration:.4f}s ({num_tasks / push_duration:.2f} tasks/sec)")
print("Processing tasks (pop + done)...")
@@ -26,7 +26,7 @@ def benchmark_femtoqueue(num_tasks: int = 1000):
break
queue.done(task)
processed += 1
- process_duration = time.time() - start
+ process_duration = time.monotonic() - start
print(
f"Processed in {process_duration:.4f}s ({processed / process_duration:.2f} tasks/sec)"
)
diff --git a/benchmark_throughput.py b/benchmark_throughput.py
index c3cae27..76bb6fa 100644
--- a/benchmark_throughput.py
+++ b/benchmark_throughput.py
@@ -14,11 +14,11 @@ def run_benchmark(duration_seconds: int, payload_size: int = 100):
total_count = 0
count_per_second = 0
- start_time = last_report_time = time.time()
+ start_time = last_report_time = time.monotonic()
try:
while True:
- now = time.time()
+ now = time.monotonic()
if now - start_time >= duration_seconds:
break
@@ -40,7 +40,7 @@ def run_benchmark(duration_seconds: int, payload_size: int = 100):
last_report_time = now
finally:
- elapsed = time.time() - start_time
+ elapsed = time.monotonic() - start_time
print("Cleaning up...")
shutil.rmtree(tmpdir)