Quote:
Originally Posted by goodsignal
in theory should be hundreds of times faster than overwriting the whole card.
|
It won't be, in fact it will almost certainly be MUCH MUCH slower. Drives and flash chips are not accessed a single byte at a time. They are accessed in pages that are on the order of many kB.
First look at the read. Reading a full page is a single instruction, "give me page X". The card then streams it to you as fast as it can, on the order of tens of MB/s. Reading one out of every 512 bytes in a page is many instructions. "give me byte Y in page X", wait for response, "give me byte Z in page X", wait for response, etc. At that point it's not the data streaming rate that will kill you, it's the back and forth command time. I would honestly be surprised if you could send 10-100 individual "give me byte Y in page X" commands and get the resulting data any faster than you could just get the entire page in one command and one data burst.
Now look at the writes. Writing to flash is a complicated process, because you can't just overwrite a byte in flash by itself. In order to write a byte, you have to clear it first, but you can't clear a single byte. You can't even clear a single page. You have to clear an entire block (many tens of pages). That means that in order to write a single byte, you have to first read the entire block, erase the entire block, then re-write the entire block with that single byte replaced with the updated value. This is called "write amplification":
https://en.wikipedia.org/wiki/Write_amplification
You can also look at benchmarks on flash drives as a function of block size, like this:
http://www.cdrlabs.com/images/storie...pro%20atto.png
That y-axis is block size in kB. Reading/Writing blocks of 512 bytes is around 175x slower than reading/writing blocks of 64 kB.
Long story short, you're far better off just erasing the entire card than trying to work a byte at a time 10,000 times.