14

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).

Thomas Calc
  • 2,994
  • 3
  • 30
  • 56
  • 2
    `What are typical data read speeds?` It varies on each system/device as it is bind with the processor and chip sets. In such the case a modern smart phone may be faster than a celeron processor computer, likewise – Lucifer Oct 24 '12 at 02:18
  • 1
    Regarding the statement "Seeking is always a slow task" in Klaus Villaca's answer, I have to disagree. It's not generally true; e.g. based on what I heard, on an SD card, it may even be **faster** than on a hard disk (due to the nature of SD card's hardware). I.e. choosing a random position may be faster than on a PC hard disk. – Thomas Calc Nov 01 '12 at 19:10

2 Answers2

2

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).

Klaus Villaca
  • 587
  • 1
  • 6
  • 11
  • 1
    Thanks for your answer. Regarding Question #4: actually, this is my most important question, and I meant it from a different aspect than how you approached it. (My software component runs in a separate thread, so responsiveness is not an issue for me.) I was actually wondering if "seek" is as efficient as on a PC hard disk. In other words, reading 2MB is not a big deal, so the question if the seeking itself is efficient or not. Because we read 2MB from a 2GB file. If seeking is not efficient, then it will take much more time than reading a separate 2MB file. On PC, seeking is efficient. – Thomas Calc Oct 31 '12 at 07:30
  • I have to disagree with the statement ""Seeking is always a slow task". It's not generally true; e.g. based on what I heard, on an SD card, it may even be faster than on a hard disk (due to the nature of SD card's hardware). I.e. reading from a random position may be faster than on a PC hard disk. – Thomas Calc Nov 01 '12 at 19:11
1

Your question is too specific and ask for too many data :-) I think it will be difficult to find another person with you very specific requirements.

In general, SD Card data access speed depends not only the driver hardware (the device) but also in the card itself and the sofware to access (the Android version).

On the other hand you can find some information regarding SD Cards speed in:

Even on Google Play you can find some apps to test the speed of a SD card on you device (search for SD Card Tester, SD Tools, etc)

rgrocha
  • 1,461
  • 10
  • 19
  • Thanks, this helped much, too (including the links). The question is not really specific, but I agree it asks for much data. Stackoverflow is also a sort of online "lexicon", so I think this is OK. :-) – Thomas Calc Oct 31 '12 at 07:35