File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
micropython/drivers/storage/sdcard Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 22# Peter hinch 30th Jan 2016
33import machine
44import os
5+ import time
56import sdcard
67
78
@@ -44,6 +45,26 @@ def sdtest():
4445 result2 = f .read ()
4546 print (len (result2 ), "bytes read" )
4647
48+ fn = "/fc/speed.bin"
49+ buf = bytearray (32768 ) # 32 KB buffer
50+
51+ print ()
52+ print ("Write speed test" )
53+ t = time .ticks_ms ()
54+ with open (fn , "wb" ) as f :
55+ for _ in range (32 ): # 1 MB total
56+ f .write (buf )
57+ elapsed = time .ticks_diff (time .ticks_ms (), t )
58+ print ("{} KB/s" .format (32768 * 32 // elapsed ))
59+
60+ print ("Read speed test" )
61+ t = time .ticks_ms ()
62+ with open (fn , "rb" ) as f :
63+ while f .readinto (buf ):
64+ pass
65+ elapsed = time .ticks_diff (time .ticks_ms (), t )
66+ print ("{} KB/s" .format (32768 * 32 // elapsed ))
67+
4768 os .umount ("/fc" )
4869
4970 print ()
You can’t perform that action at this time.
0 commit comments