This is my parallel processing code where I am comparing the runtimes of parallel codes and linear codes of the same task in Python. I am getting the output time for parallel code to be more in every run. This is completely unexpected. Why is it happening? What's wrong?
from multiprocessing import Pool
import matplotlib.pyplot as plt
import numpy as np
import time
def scatter_join(args):
plt.scatter(s=1,*args)
plt.savefig('test_p.png')
if __name__ == '__main__':
p = Pool()
snap = np.random.randint(0,20,(100000,2))
task = [(snap[:,0],snap[:,1])]
t = time.time()
p.map(scatter_join,task)
p.close()
p.join()
print('Time Elapsed(Parallel): ', abs((time.time()-t)))
plt.clf()
t = time.time()
plt.scatter(snap[:,0],snap[:,1],s=1)
plt.savefig('test_l.png')
print('Time Elapsed(Linear): ',abs(time.time()-t))