Created
May 4, 2017 21:26
-
-
Save seth10/96676949520a7f0cd8f2676641ae90f7 to your computer and use it in GitHub Desktop.
Measure how long each step of drawing the graph takes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while not stop: | |
start = time.time() | |
plt.cla() # clear axis, get rid of old lines | |
print "Clear:\t", time.time()-start | |
start = time.time() | |
slicedata = data[:,-1*DATA_SIZE:] # use only the last n data points, where n is DATA_SIZE | |
print "Slice:\t", time.time()-start | |
start = time.time() | |
# plot a spline (smooth line) for each axis | |
for i in range(3): plt.plot(smooth_x, spline(np.arange(len(slicedata[i])), slicedata[i], smooth_x)) | |
print "Spline:\t", time.time()-start | |
start = time.time() | |
canvas.draw() | |
print "Draw:\t", time.time()-start | |
start = time.time() | |
# directly write the matplotlib canvas to the PiStorms screen (faster than using an intermediary) | |
disp.buffer = Image.frombytes('RGB', canvas.get_width_height(), canvas.tostring_rgb()).rotate(-90*psm.screen.currentRotation) | |
print "Buffer:\t", time.time()-start | |
start = time.time() | |
disp.display() # update the screen | |
print "Display:", time.time()-start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment