|
3 | 3 | from a_module.fast_file import fast_function
|
4 | 4 | from b_module.slow_file import slow_function
|
5 | 5 |
|
6 |
| -DURATION = 60 * 10 # ten minutes |
| 6 | +ITERATIONS = 20000 |
7 | 7 |
|
8 | 8 | 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') |
30 | 14 |
|
31 | 15 | print(f'Switching fast and slow around.....')
|
32 |
| - time.sleep(60) |
| 16 | + time.sleep(20) |
33 | 17 | print(f'Switching fast and slow around.....')
|
34 | 18 |
|
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