SHARE
TWEET

Untitled

a guest Mar 23rd, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from multiprocessing import Process
  2. from time import time
  3. import os
  4.  
  5. def f(num):
  6.     a = num*num*num*num
  7.     process_id = os.getpid()
  8.     print('id: ' + str(process_id))
  9.  
  10. if __name__ == '__main__':
  11.     board_index = [1,2,3,4,5,6]
  12.     processes = []
  13.     t1 = time()
  14.     for i in range(len(board_index)):
  15.         p = Process(target=f, args=(board_index[i],))
  16.         processes.append(p)
  17.         p.start()
  18.         p.join()
  19.     t2 = time()    
  20.  
  21.     print('ez a multiprocesses eredmény: ' + str(t2-t1))
  22.     t3 = time()
  23.     for i in range(len(board_index)):
  24.         f(board_index[i])
  25.     t4 = time()
  26.     print('ez a sima: ' + str(t4-t3))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top