##// END OF EJS Templates
Merge pull request #2179 from dopplershift/pylab-switch...
Merge pull request #2179 from dopplershift/pylab-switch Enable switching %pylab mode between inline and a single gui mode in a single notebook. With this merge, `%pylab` can be called interactively to toggle inline/GUI (matplotlib floating windows) mode. After initializing `%pylab inline`, now one can call `%pylab` without arguments to activate the default GUI or ask for a specific one as usual. IPython will detect if a different GUI is requested if one was already activated and will refuse to do so (to prevent multiple event loops from running concurrently, which often leads to problems).

File last commit:

r6455:15863dc1
r8027:6dac6929 merge
Show More
throughput.py
66 lines | 1.5 KiB | text/x-python | PythonLexer
Thomas Kluyver
Update print syntax in parallel examples.
r6455 from __future__ import print_function
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564 import time
import numpy as np
MinRK
move IPython.zmq.parallel to IPython.parallel
r3666 from IPython import parallel
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564
nlist = map(int, np.logspace(2,9,16,base=2))
nlist2 = map(int, np.logspace(2,8,15,base=2))
tlist = map(int, np.logspace(7,22,16,base=2))
nt = 16
def wait(t=0):
import time
time.sleep(t)
def echo(s=''):
return s
def time_throughput(nmessages, t=0, f=wait):
MinRK
move IPython.zmq.parallel to IPython.parallel
r3666 client = parallel.Client()
MinRK
update a few parallel examples...
r4184 view = client.load_balanced_view()
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564 # do one ping before starting timing
if f is echo:
t = np.random.random(t/8)
view.apply_sync(echo, '')
client.spin()
tic = time.time()
for i in xrange(nmessages):
view.apply(f, t)
lap = time.time()
MinRK
update a few parallel examples...
r4184 client.wait()
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564 toc = time.time()
return lap-tic, toc-tic
def do_runs(nlist,t=0,f=wait, trials=2, runner=time_throughput):
A = np.zeros((len(nlist),2))
for i,n in enumerate(nlist):
t1 = t2 = 0
for _ in range(trials):
time.sleep(.25)
ts = runner(n,t,f)
t1 += ts[0]
t2 += ts[1]
t1 /= trials
t2 /= trials
A[i] = (t1,t2)
A[i] = n/A[i]
Thomas Kluyver
Update print syntax in parallel examples.
r6455 print(n,A[i])
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564 return A
def do_echo(n,tlist=[0],f=echo, trials=2, runner=time_throughput):
A = np.zeros((len(tlist),2))
for i,t in enumerate(tlist):
t1 = t2 = 0
for _ in range(trials):
time.sleep(.25)
ts = runner(n,t,f)
t1 += ts[0]
t2 += ts[1]
t1 /= trials
t2 /= trials
A[i] = (t1,t2)
A[i] = n/A[i]
Thomas Kluyver
Update print syntax in parallel examples.
r6455 print(t,A[i])
MinRK
added py4science demos as examples + NetworkX DAG dependencies
r3564 return A
Thomas Kluyver
Update print syntax in parallel examples.
r6455