From 30fbb7bac208b36ebded166adccb9f49fd4a02b4 Mon Sep 17 00:00:00 2001 From: Elliot Kim Date: Mon, 2 Dec 2024 18:48:05 -0500 Subject: [PATCH] fixed throughput python api test --- test-vine-task-throughput.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test-vine-task-throughput.py b/test-vine-task-throughput.py index d1be66f..513ef7a 100644 --- a/test-vine-task-throughput.py +++ b/test-vine-task-throughput.py @@ -4,7 +4,7 @@ import time import sys -if __name__ == "__main__": +def main(): q = vine.Manager() print("listening on port", q.port) @@ -29,11 +29,11 @@ start = time.time() start_timer = False - end = time.time() - many = end - start + end = time.time() + many = end - start - start = time.time() - with factory: + start = time.time() + for i in range(num_tasks): while not q.empty(): result = q.wait(5) @@ -41,8 +41,8 @@ task_id = q.submit(t) print("waiting for tasks to complete...") - end = time.time() - one = end - start + end = time.time() + one = end - start throughput = num_tasks/many chaining = num_tasks/one print(f"\nThroughput was {throughput} tasks per second") @@ -50,6 +50,9 @@ print("all tasks complete!") assert throughput >= 190 assert chaining >= 155 - + +if __name__ == '__main__': + main() + # vim: set sts=4 sw=4 ts=4 expandtab ft=python: