In [157]:
import numpy as np
import numba
import multiprocessing as mp
from concurrent.futures import ThreadPoolExecutor
from joblib import Parallel, delayed
import matplotlib.pyplot as plt
In [ ]:
In [148]:
def plot_one(data, name):
xs, ys = data.T
plt.scatter(xs, ys, s=1, edgecolor=None)
plt.savefig('%s.png' % name)
In [149]:
data = np.random.random((10, 10000, 2))
In [150]:
%%time
for i, M in enumerate(data):
plot_one(M, i)
In [152]:
%%time
args = [(x, i) for i, x in enumerate(data)]
with ThreadPoolExecutor() as pool:
pool.map(lambda x: plot_one(*x), args)
In [155]:
%%time
args = [(x, i) for i, x in enumerate(data)]
with mp.Pool() as pool:
pool.starmap(plot_one, args)
In [159]:
%%time
Parallel(n_jobs=-1)(delayed(plot_one)(x, i) for i, x in enumerate(data))
pass
In [ ]: