-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiprocessing3.py
More file actions
34 lines (26 loc) · 886 Bytes
/
Multiprocessing3.py
File metadata and controls
34 lines (26 loc) · 886 Bytes
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
import time
import multiprocessing
def DisplayEven(no):
for i in range(1,no+1,1):
if(i % 2 == 0):
print("Even number : ",i)
def DisplayOld(no):
for i in range(1,no+1,1):
if(i % 2 != 0):
print("Odd number : ",i)
def main():
print("Demostration of parallel programming using multiple processess")
number = 200
p1 = multiprocessing.Process(target = DisplayEven, args = (number , ))
p2 = multiprocessing.Process(target = DisplayOld, args = (number , ))
p1.start()
p2.start()
print("End of main")
if __name__ == '__main__':
# execution time of process
start_time = time.process_time()
main()
end_time = time.process_time()
print("start time is : ",start_time)
print("End time is : ",end_time)
print("Execution time is : ", end_time - start_time)