If you want to get the highest performance out of your SD cards then read on. The purpose of this article is to raise awareness and spark your curiosity about SD card performance considerations.
Many developers I talk to aren’t aware that the read/write speeds of SD memory cards can have a significant affect on performance. This is especially true if you are moving around lots of data between a smartphone and the SD card. The good news is there is quite a bit of information out there to help you maximize performance, and a lot of it comes from high-end, camera aficionados believe it or not.
The most common feedback I get is developers typically buy cards with the most capacity at the lowest price. Depending on what you are doing, cheapest and slower isn’t always better. With little bit of research your read/write performance could get significantly better.
To start with there are four common speed classes: 2, 4, 6 and 10 and they represent an approximate minimum performance rating. You can find this number on the front of your card:
- Class 2 ~ 2 Mbytes/sec
- Class 4 ~ 4 Mbytes/sec
- Class 6 ~ 6 Mbytes/sec
- Class 10 ~ 10 Mbytes/sec
Read/write performance to your phones SD card really depends on HOW your application reads and writes data. You may have to do some testing to find out what works best. It depends on the consideration of multiple factors including:
- Typical file types (e.g. video vs. text vs. image, etc)
- Average file or data transaction size
- Percentage of reads to writes
- Duty cycle (percentage of reads or writes over a fixed time period)
- Usage pattern
Usage pattern deserves a bit more attention and really starts to tell the story of what your application does behind-the-scenes. I think the best way to describe it is through some common use cases:
- Many small reads and writes to/from a local database.
- Occasional small reads and writes to local database.
- Occasional large reads from local database.
- Occasional large reads and writes to/from local database.
- Large read upon application startup and large write upon application shutdown.
Wikipedia has noted that speed can differ significantly depending on what you are writing to the card. The article notes that writing large files versus writing many small files has widely different affects on performance. I’d seen similar observations when I worked on ultra-high performance server systems. So, the concept still remains today and provides excellent hints on how to tweak every extra millisecond of user experience.
If you need maximum performance then consider reformatting or defragging your card on a regular basis. I know Windows disk defragmenter utilities work on most SD cards, not sure about Mac. I have also seen multiple articles talk about bigger capacity is better because of memory fragmentation. With memory fragmentation, the card speed starts to decrease over time as the data becomes more fragmented. It’s the same concept as when you “defrag” the hard drive on your laptop.
References
If you want to learn more here are some helpful links:
Wikipedia – Secure Digital (See Speed Class Rating section)
Does your camera need a fast SD card? (good insight into SD card speed)