Question: Modify the example, describe what you've done, and explain the expected outcome, the actual outcome with screen captures of your code executions. He didn't specify

Modify the example, describe what you've done, and explain the expected outcome, the actual outcome with screen captures of your code executions.
He didn't specify what needs to be changed so basically anything you see where can be improvement.
1 from multiprocessing import * 2 3 def addNumbers (numNumbers): 4 S=0 5 for i in range (numNumbers): 6 s = s + random.randint(1, 100) 7 prints 8 9 def comparePar Seq(): 10 totalNumNumbers 1000000 11 12 # START TIMING PARALLEL 13 start Time time.time() 14 pl Process (target=addNumbers, args=(totalNumNumbers/2,)) 15 p2 = Process (target=addNumbers, args=(totalNumNumbers/2,)) 16 pl.start() 17 p2.start() 18 19 # Wait until processes are done 20 pl.join() 21 p2.join() 22 23 par Time = time. time() start Time 24 # DONE TIMING PARALLEL 25 print "It took", parTime, "seconds to compute in parallel." 26 27 # START TIMING SEQUENTIAL 28 start Time time.time) 29 30 31 for i in range (totalNumNumbers): 32 s = s + random.randint(1, 100) 33 34 seq Time time.time() - start Time 35 # DONE TIMING SEQUENTIAL 36 print It took", seqTime, "seconds to compute sequentially." 37 38 print "Speedup: ", seqTime / parTime S = 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
