Created
August 9, 2017 21:59
-
-
Save sethcohn/8ee563517b95a9a19ce55636a7665bd9 to your computer and use it in GitHub Desktop.
Pixel Time Trials - for testing write speeds in CircuitPython
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
from board import * | |
import time | |
import urandom | |
import neopixel | |
pininuse = A0 #change for your board pin | |
strandsize = 144 | |
stepsize = 10 | |
startingpixel = 5 | |
color = (30,0,0) | |
trialcount = 5 | |
def timedrun(trials,pixels,color,autow): | |
# combined will be divided by trial total, set once before the trials | |
setcombined = 0 | |
writecombined = 0 | |
#set low to high value, so it'll be replaced | |
setlow = 60 | |
writelow = 60 | |
#set high to low value, so it'll be replaced | |
sethigh = 0 | |
writehigh = 0 | |
for trial in range (0, trials): # # of trials, take high, low, and average | |
with neopixel.NeoPixel(pininuse, pixels, 3, 1, autow) as np: # change to match pin and pixel count | |
#np.auto_write = autow | |
starttime = time.monotonic() | |
for i in range(0, pixels): | |
np[i] = color | |
writestop = time.monotonic() | |
np.show() | |
showstop = time.monotonic() | |
#collect data on run | |
settime = writestop - starttime | |
setcombined += settime | |
if settime > sethigh: | |
sethigh = settime | |
if settime < setlow: | |
setlow = settime | |
writetime = showstop - writestop | |
writecombined += writetime | |
if writetime > writehigh: | |
writehigh = writetime | |
if writetime < writelow: | |
writelow = writetime | |
print (trials, color, autow, pixels, setlow, setcombined/trials, sethigh, writelow, writecombined/trials, writehigh) | |
def pixeltimetrials(): | |
print ("trials", "color", "autowrite", "#pixels", "setlow", "setavg", "sethigh", "writelow", "writeavg", "writehigh") | |
for size in range(startingpixel, strandsize, stepsize): #144 neopixel strand tested, 10-140 | |
timedrun(trialcount, size, color, True) #auto_write True | |
timedrun(trialcount, size, color, False) #auto_write False | |
print ("Trial run complete") | |
pixeltimetrials() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment