Created
October 23, 2018 15:38
-
-
Save jsbain/1df982ee81e78ae8958b073fa7194a9c to your computer and use it in GitHub Desktop.
screenspeedtest.py
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
import ui, io, Image, matplotlib.image,numpy, timeit | |
print(__file__) | |
A=numpy.random.rand(300,300,3) | |
Au=(255*A).astype('uint8') | |
B=io.BytesIO() | |
def p(format='jpeg'): | |
B.seek(0) | |
Image.fromarray(Au).save(B,format=format) | |
return ui.Image.from_data(B.getvalue()) | |
def m(format='jpeg'): | |
B.seek(0) | |
matplotlib.image.imsave(B,A,format=format) | |
return ui.Image.from_data(B.getvalue()) | |
N=30 | |
print('matplotlib jpeg') | |
print(N/timeit.timeit('m("jpeg")',number=N, globals=globals()), 'fps') | |
print('pil jpeg') | |
print(N/timeit.timeit('p("jpeg")',number=N, globals=globals()), 'fps') | |
print('matplotlib png') | |
print(N/timeit.timeit('m("png")',number=N, globals=globals()), 'fps') | |
print('pil png') | |
print(N/timeit.timeit('p("png")',number=N, globals=globals()), 'fps') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment