Skip to content

Commit 8e39892

Browse files
committed
changes from time to iterations
1 parent d0522ae commit 8e39892

File tree

1 file changed

+12
-48
lines changed

1 file changed

+12
-48
lines changed

examples/python/main.py

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,21 @@
33
from a_module.fast_file import fast_function
44
from b_module.slow_file import slow_function
55

6-
DURATION = 60 * 10 # ten minutes
6+
ITERATIONS = 20000
77

88
if __name__ == "__main__":
9-
t_start = time.time()
10-
t_end = time.time() + DURATION
11-
12-
print(f'yoyoy Application started at: {t_start}')
13-
while time.time() < t_end:
14-
threads = list()
15-
fast_thread = threading.Thread(target=fast_function, args=(25000,))
16-
slow_thread = threading.Thread(target=slow_function, args=(8000,))
17-
18-
threads.append(fast_thread)
19-
fast_thread.start()
20-
21-
threads.append(slow_thread)
22-
slow_thread.start()
23-
24-
for index, thread in enumerate(threads):
25-
# print("Main : before joining thread %d.", index)
26-
thread.join()
27-
# print("Main : thread %d done", index)
28-
29-
print(f'yoyoy Application ended at: {t_end}')
9+
print(f'yoyoy Application 1 started')
10+
for i in range(ITERATIONS):
11+
fast_function(25000)
12+
slow_function(8000)
13+
print(f'yoyoy Application 1 ended')
3014

3115
print(f'Switching fast and slow around.....')
32-
time.sleep(60)
16+
time.sleep(20)
3317
print(f'Switching fast and slow around.....')
3418

35-
t_start = time.time()
36-
t_end = time.time() + DURATION
37-
38-
print(f'yoyoy Application started at: {t_start}')
39-
while time.time() < t_end:
40-
threads = list()
41-
fast_thread = threading.Thread(target=fast_function, args=(25000,))
42-
slow_thread = threading.Thread(target=slow_function, args=(75000,))
43-
44-
threads.append(fast_thread)
45-
fast_thread.start()
46-
47-
threads.append(slow_thread)
48-
slow_thread.start()
49-
50-
for index, thread in enumerate(threads):
51-
# print("Main : before joining thread %d.", index)
52-
thread.join()
53-
# print("Main : thread %d done", index)
54-
55-
print(f'yoyoy Application ended at: {t_end}')
56-
57-
58-
59-
19+
print(f'yoyoy Application 2 started')
20+
for i in range(ITERATIONS):
21+
fast_function(25000)
22+
slow_function(75000)
23+
print(f'yoyoy Application 2 ended')

0 commit comments

Comments
 (0)