Code: Select all
$ sync; time dd if=/dev/zero of=~/test.tmp bs=500K count=1024; time sync
Starts out by doing "sync" which flushes any data that should be on disk, but is still in memory, to disk.
Then it runs "dd" under the "time" command. This writes a load of stuff to test.tmp and tells you how long it took.
Then it runs "sync" again. This time under the "time" command. This flushes everything written by "dd" command from memory buffers to disk and tells you how long it took.
I guess the idea is to add the time recorded for dd and the time taken for that second sync to give the total time to write everything to the SD.
What gets written? Well as it says, the input (if) to dd is /dev/zero. That is not a real file but a device driver that just returns an endless stream of zero bytes.
How big is test.tmp?. That would be "count" blocks times bs (block size) bytes. In this case 500 thousand times 1024. Or about 500 mega bytes.
There you go.
In my experience this kind of test often leads to a whole bunch of block errors from the SD driver followed by file system corruption. I have not found many reliable SD cards for use on the Pi or similar ARM boards running Linux.
So be sure you have your data backed up and a bunch of spare SD cards.
Memory in C++ is a leaky abstraction .