%pylab inline import time import numpy as np from IPython.parallel import Client rc = Client() def f(x): import random, time time.sleep(3 * random.random()) return x lview = rc.load_balanced_view() def scale_submit(view, f, nlist): sends = [] for n in nlist: time.sleep(1) x = range(n) tic = time.time() amr = view.map_async(f, x) sent = time.time() - tic print " sent %6i tasks in %6i ms" % (n, 1000 * sent) sys.stdout.flush() sends.append(sent) return sends nlist = [ 2 ** p for p in range(1,16) ] nlist def plot_tasks_per_sec(ns, ts): ns = np.array(ns) ts = np.array(ts) plt.loglog(ns, ns/ts, '-o', label="measured") # plt.ylim(0,5e3) plt.xlabel("n") plt.ylabel("tasks/sec") nlist = nlist[:-2] sent = scale_submit(lview, f, nlist) plot_tasks_per_sec(nlist, sent) sent = scale_submit(lview, f, nlist) plot_tasks_per_sec(nlist, sent)