back to Index
2014-07-19
In [69]:
import gevent
In [70]:
import time
import numpy as np
In [71]:
supertime=np.zeros(shape=[100,1000], dtype=float32)
In [72]:
def time_test(times):
last_time=time.time()
for i in range(supertime.shape[1]):
now=time.time()
times[i]=now-last_time
last_time=now
gevent.sleep(.005)
In [74]:
threads=[]
for i in range(supertime.shape[0]):
threads.append(gevent.spawn(time_test, supertime[i]))
In [75]:
for thread in threads:
thread.start()
In [76]:
gevent.joinall(threads)
In [16]:
%matplotlib inline
In [22]:
rcParams['font.family']= 'serif'
# rcParams['font.weight']= 'bold'
rcParams['font.serif']= 'cmr10'
rcParams['font.size']= 22
rcParams['text.usetex'] = False
rcParams['figure.figsize'] = 10, 8
rcParams['figure.subplot.left'] = 0.08
rcParams['figure.subplot.right'] = 0.92
rcParams['figure.subplot.bottom'] = 0.08
rcParams['figure.subplot.top'] = 0.92
rcParams['figure.subplot.wspace'] = 0.25
rcParams['figure.subplot.hspace'] = 0.25
rcParams['savefig.dpi'] = 300
rcParams['ps.fonttype'] = 42
rcParams['pdf.fonttype'] = 42
In [23]:
import matplotlib.pyplot as plt
In [86]:
plt.imshow(supertime, interpolation='nearest', aspect='auto')
plt.colorbar()
plt.title('Jitter from 100 gevent threads running at 100hz')
plt.xlabel('Time(ms)')
plt.ylabel('Thread Id')
plt.clim(0, .02)
In [87]:
for i in range(supertime.shape[0]):
plt.plot(supertime[i])
plt.title('Jitter from 100 gevent threads running at 100hz')
plt.xlabel('Time(ms)')
plt.ylabel('Period(s)')
pylab.ylim([0,.02])
Out[87]:
In [ ]: