Measuring Throughput, Data Transfer Rate, and Memory Bandwidth on SRAM

raygun3000:
Essentially, I have a microcontroller that has 8MHz clock speed which is 4Mbit/sec or 500KByte/sec so I'm still getting around the 1/4 theoretical rate.

And this means the "avoidable" overhead actually isn't the culprit.

And is not that bad, 125 KB/s is more or less what I would, at most, expect for SD card read speed.

Looks like a DMA (what an Arduino lacks) really would make it faster without overclocking.

raygun3000:
I know the write() function could also take in a buffer and length but I also want to have "," to separate them in a .csv file. Maybe I could mess with the predefined buffer and use it as a string first and later converting back to bytes? :-\

If you want, but be aware that the printing (binary to text) process might become a bottleneck in some cases.

To minimize this effect, you can print directly into a buffer rather than the stream itself:

sprintf(yourBuffer, "%d, ", value); // for all values but the last

sprintf(yourBuffer, "%d\r\n", value); // for the last value only, it also creates a new line

Although not sure if it makes any difference, since both sprintf() and File.print() write a buffer anyway.

PD: not sure how exactly you tested the SD card, even on a 8 MHz system I would expect something close to 30 KB/s. My test was made at 16 MHz, so no doubt why mine gave more.