The time to do a write depends on the card and the state of the card. The SD spec allow a card to take as long as 200 ms.
Run the SdFat bench example. it will print the max latency. Here is output for a typical card with a max latency of 156 ms:
Type any character to start
Free RAM: 1035
Type is FAT16
File size 5MB
Starting write test. Please wait up to a minute
Write 192.83 KB/sec
Maximum latency: 155956 usec, Avg Latency: 513 usec
Starting read test. Please wait up to a minute
Read 295.49 KB/sec
Maximum latency: 2808 usec, Avg Latency: 333 usec
Free RAM: 1043
Type is FAT16
File size 5MB
Starting write test. Please wait up to a minute
Write 86.71 KB/sec
Maximum latency: 163952 usec, Avg Latency: 1143 usec
Starting read test. Please wait up to a minute
Read 142.85 KB/sec
Maximum latency: 5392 usec, Avg Latency: 690 usec
So what does the lantency mean? Is it to access the SD card (initialize, open the file,...)?
So the total time will be the latency (163 ms) + write time for 150 bytes (150B/86.7kB/s = 1.7 ms) or maybe write time for a block (5,8 ms), or maybe even write time for 2 blocks if the data spans 2 blocks?
Any idea how much power a common microSD card uses? Will it use a lot power durring the latency time?
The bench example writes 100 bytes at a time. The bench example writes a five MB file so 50,000 write calls are executed.
The maximum latency is the maximum time to execute this statement:
file.write(buf, sizeof(buf))
Where buf is a 100 byte array.
A latency of over 300 ms is unusually long. 150-200 ms is more common.
The maximum latency generally occurs when a SD card erases a large number of blocks of flash memory. It can also be related to wear leveling or remapping a bad spot.