|
4 | 4 | import time |
5 | 5 | import sys |
6 | 6 |
|
| 7 | +def func(): |
| 8 | + return |
| 9 | + |
7 | 10 | def main(): |
8 | 11 |
|
9 | 12 | q = vine.Manager() |
| 13 | + print("Creating Library from functions...") |
| 14 | + function_lib = q.create_library_from_functions('test-library', func, add_env=False) |
| 15 | + q.install_library(function_lib) |
| 16 | + |
10 | 17 | print("listening on port", q.port) |
11 | 18 | factory = vine.Factory("local",manager_host_port="localhost:{}".format(q.port)) |
12 | 19 | factory.max_workers=1 |
@@ -43,14 +50,45 @@ def main(): |
43 | 50 | print("waiting for tasks to complete...") |
44 | 51 | end = time.time() |
45 | 52 | one = end - start |
46 | | - throughput = num_tasks/many |
47 | | - chaining = num_tasks/one |
| 53 | + throughput = num_tasks/many |
| 54 | + chaining = num_tasks/one |
| 55 | + #serverless tasks |
| 56 | + for i in range (num_tasks): |
| 57 | + t = vine.FunctionCall('test-library', 'func') |
| 58 | + task_id = q.submit(t) |
| 59 | + |
| 60 | + print("Waiting for tasks to complete...") |
| 61 | + start_timer = True |
| 62 | + while not q.empty(): |
| 63 | + t = q.wait(5) |
| 64 | + if start_timer: |
| 65 | + start = time.time() |
| 66 | + start_timer = False |
| 67 | + end = time.time() |
| 68 | + serverless_many = end - start |
| 69 | + |
| 70 | + start = time.time() |
| 71 | + for i in range(num_tasks): |
| 72 | + while not q.empty(): |
| 73 | + result = q.wait(5) |
| 74 | + t = vine.FunctionCall('test-library', 'func') |
| 75 | + task_id = q.submit(t) |
| 76 | + end = time.time() |
| 77 | + serverless_one = end-start |
| 78 | + serverless_throughput = num_tasks/serverless_many |
| 79 | + serverless_chaining = num_tasks/serverless_one |
| 80 | + |
| 81 | + |
48 | 82 | print(f"\nThroughput was {throughput} tasks per second") |
49 | 83 | print(f"Chaining was {chaining} tasks per second") |
| 84 | + print(f"\nServerless Throughput was {serverless_throughput} tasks per second") |
| 85 | + print(f"Serverless Chaining was {serverless_chaining} tasks per second") |
50 | 86 | print("all tasks complete!") |
51 | | - assert throughput >= 190 |
52 | | - assert chaining >= 155 |
53 | | - |
| 87 | + assert throughput >= 190, "Throughput in python api is less than required 190" |
| 88 | + assert chaining >= 155, "Throughput for chaining in python api is less than required 155" |
| 89 | + assert serverless_throughput >= 110, "Throughput using serverless is less than required 190" |
| 90 | + assert serverless_chaining >= 50, "Throughput for chaining using serverless is less than required 155" |
| 91 | + |
54 | 92 | if __name__ == '__main__': |
55 | 93 | main() |
56 | 94 |
|
|
0 commit comments