On 2017-07-03 20:47, Xristos Xristoou wrote:
i have create an image processing python function.

my system have 4 cores + 4 threads.

i want to use multiprocessing to speed up my function,but anytime to use 
multiprocessing packages my function is not faster and is 1 minute slowly. any 
idea why ?first time use multiprocessing packages.

main function :

if __name__ == '__main__':
     in_path="C:/Users/username/Desktop/in.tif"
     out_path="C:/Users/username/Desktop/out.tif"
     myfun(in_path, out_path)
time=3.4 minutes

with multiprocessing map :

if __name__ == '__main__':
     p = Pool(processes=4)
     in_path="C:/Users/username/Desktop/in.tif"
     out_path="C:/Users/username/Desktop/out.tif"
     result = p.map(myfun(in_path,out_path))
time=4.4 minutes

if __name__ == '__main__':
     pool = multiprocessing.Pool(4)
     in_path="C:/Users/username/Desktop/in.tif"
     out_path="C:/Users/username/Desktop/out.tif"
     pool.apply_async(myfun, args=(in_path,out_path,))
     pool.close()
     pool.join()
time=4.5 minutes

It looks like you have one function performing one task. It's not splitting the task into multiple parts that can be run in parallel on multiple cores.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to