-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-vine-task-throughput.py
93 lines (71 loc) · 2.51 KB
/
test-vine-task-throughput.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python
import ndcctools.taskvine as vine
import time
import sys
def func():
return
def main():
q = vine.Manager()
print("Creating Library from functions...")
function_lib = q.create_library_from_functions('test-library', func, add_env=False)
q.install_library(function_lib)
print("listening on port", q.port)
factory = vine.Factory("local",manager_host_port="localhost:{}".format(q.port))
factory.max_workers=1
factory.min_workers=1
num_tasks = 1000
with factory:
for i in range(num_tasks):
t = vine.Task(command=":")
task_id = q.submit(t)
print("waiting for tasks to complete...")
start_timer = True
while not q.empty():
t = q.wait(5)
if start_timer:
start = time.time()
start_timer = False
end = time.time()
many = end - start
start = time.time()
for i in range(num_tasks):
while not q.empty():
result = q.wait(5)
t = vine.Task(command=":")
task_id = q.submit(t)
print("waiting for tasks to complete...")
end = time.time()
one = end - start
throughput = num_tasks/many
chaining = num_tasks/one
#serverless tasks
for i in range (num_tasks):
t = vine.FunctionCall('test-library', 'func')
task_id = q.submit(t)
print("Waiting for tasks to complete...")
start_timer = True
while not q.empty():
t = q.wait(5)
if start_timer:
start = time.time()
start_timer = False
end = time.time()
serverless_many = end - start
start = time.time()
for i in range(num_tasks):
while not q.empty():
result = q.wait(5)
t = vine.FunctionCall('test-library', 'func')
task_id = q.submit(t)
end = time.time()
serverless_one = end-start
serverless_throughput = num_tasks/serverless_many
serverless_chaining = num_tasks/serverless_one
print(f"\nThroughput was {throughput} tasks per second")
print(f"Chaining was {chaining} tasks per second")
print(f"Serverless Throughput was {serverless_throughput} tasks per second")
print(f"Serverless Chaining was {serverless_chaining} tasks per second")
print("all tasks complete!")
if __name__ == '__main__':
main()
# vim: set sts=4 sw=4 ts=4 expandtab ft=python: