static void SendFrame(object o) { t1 = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks; filestream.Read(block, 0, blockSize); t2 = Microsoft.SPOT.Hardware.Utility.GetMachineTime().Ticks; Debug.Print((t2 - t1).ToString()); spi.Write(block); if (filestream.Position >= filestream.Length) { filestream.Seek(0, 0); //rewind the file Debug.Print("File end!"); } }
The test candidate was a 173 kByte file on a Transcend 2 gig microSD card, and each test case loops through the file 5-6 times. Trying a few block sizes, I found the following:
Block Size Time (us) Time/byte (us) kBytes/sec 511 3218.48 6.30 158.770 512 3249.21 6.35 157.577 723 4524.63 6.26 159.792 1024 6326.45 6.18 161.860 2048 12551.00 6.13 163.174 4096 24678.56 6.03 165.974
Note that these are aggregate numbers, the actual value for each read was very bimodal for the smaller blocks, with minimum read times of around 1.07ms and maximum read times of 13.46 ms/block. The 4096 byte block read time was very consistent, at 24.93ms per block, with the first read always coming in at half that.