Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File reading performance on smartphones: internal storage vs. SD card vs. PC hard disk

My Android application will use big and very big files (i.e. between the size of 10MB and 2GB).

I've always been wondering about what hardware is used by smartphones for stable storage, and whether the software (file reading/seeking) considerations are similar here as for PC hard disks. I tried to find information about hardware and have some sort of picture about it (internal storage, SD card), but none of the sources I checked are comprehensive and/or specific enough. My (interrelated) questions are:

  1. What are the major differences that I must take into account when reading big files on a "modern" smartphone (e.g. on an Android 2.2. phone), compared to doing the same thing with a Java application for a PC? (in terms of disk seeking/reading performance; obviously, cellphone RAM is smaller than in a PC, so this must be taken into account in case of buffers etc.)
  2. What are the (relevant) major differences between the stable storage hardware used in smartphones compared to PC hard disks? (I know this is a very wide question, so I even appreciate a very brief answer here and possibly a few reliable external URLs)
  3. In terms of InputStream reading and seeking (skipBytes), is there a difference (e.g. on Android) between using the internal storage and the SD card (I intentionally didn't write "external storage", because it's not necessarily the SD card on every device)? Is the SD card slower?
  4. For example, I would like to read 2MB of data from a 2GB file, and this 2MB data is distributed in many different/distant parts of the file. All offsets are known, so I create an ascending order of offsets and then use BufferedInputStream.read() (e.g. in a DataInputStream) to read them (and using skipBytes() for seeking wherever necessary). Therefore, in the underlying file system, this may require "going through" the entire 2GB file. (E.g. Android uses the linux functions to seek in the file when needed.) However, is seeking as efficient as in a PC hard disk? What about the SD card vs. internal storage in terms of seek efficiency?
  5. What are typical data read speeds? (smartphone internal storage vs. SD card vs. PC non-SSD hard disk)

I know benchmarking for my concrete application is a must, but I would welcome a theoretical clarification in the matter as well.

IMPORTANT: when I ask that "... is seeking as efficient as in a PC hard disk?", I don't (only) mean the absolute values but also the mechanism of it. That is, if it works based on the same logical principles (= skipping large parts whenever possible), or there are some drawbacks (e.g. such "skipping-based" seeking is not possible on an SD card, and thus skipping is much more -- i.e. non-proportionally -- useless on a smartphone hardware than on a PC hard disk).

like image 632
Thomas Calc Avatar asked Oct 24 '12 01:10

Thomas Calc


1 Answers

Trying to answer your questions

  1. There's only one difference, that's if your files are into the app package (within app), because you need to open it using a different method, however if it's inside app package and into package/file/ than you can use the same File file bla.. .

  2. Smartphones internal memory is faster than HDD, though ifyou store it in a external SDCard, this will change due that SDCards have maximum speed for read and write.

  3. Yes there is differences... if reading from internal or SDCard (not the external SD card), other else we shouldn't have devices with 1 or 2GB and 16Gb for storage. Everything that it's within that main memory will run faster.

  4. Seeking is always a slow task, you can once got all date that you need close the stream, even if you didn't have reached the end of the file. What you can do to get faster is go reloading a cache everytime that your app has readed some amount of KBs or MBs... than you can lunch a asyncTask to go loading it, and once the main thread has finished will look for more data if exist. This should speed up a lot, because you will be searching just in memory.

  5. You will need a app for that or write your own, that shouldn't be too difficult, you can use handler, and load as much as you can in an array or list, and count the bytes, and repeat it on other memory types (internal SD card and external SDCard).

like image 82
Klaus Villaca Avatar answered Sep 21 '22 13:09

Klaus Villaca