User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

file read write speed test

Wed Jun 14, 2017 2:58 am

always little late i just play USB boot, and i wanted to know
if there is a big difference between the 3 way to run RPI OS ( Raspbian )
+ from SD card ( in SD card slot ) ( RPI default operation )
+ from SD card ( in USB card reader ) in USB port
+ from USB stick

i not used this file read write speed tests for a long time ( so actually never on a RPI3 ) and now i am very confused by the results.
i was used to 4MB/sec with a bad SD card, 12MB/sec with my best.
now i see more as 5 times that speed

digging up a other test in internet i see possible write speeds (13MB/sec )
but for read crazy numbers like GB/sec

all that can't be right!
so i try to test the test routines with a RPI2, but with nearly the same high numbers.
can you pls take a look http://kll.engineering-news.org/kllfusi ... 0#example2 here,
what am i doing wrong?
or can there have been changes in the OS what speed up file I/O that much?
Last edited by KLL on Wed Jun 14, 2017 4:00 am, edited 1 time in total.

W. H. Heydt
Posts: 11064
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: file read write speed test

Wed Jun 14, 2017 3:32 am

Just to begin with, you need to do a "sync" command after any write as the data may be sitting in OS disk cache and not be written at all. Not doing a sync will give you a low time/high data rate that doesn't reflect the actual write speed

It's been a while, .but my last set of tests with a Pi3B gave me reading and writing speeds around 30MB/s to 35MB/s and file-to-file copy speeds roughly half that. Speeds were very similar using a PiDrive, a USB 3 stick and an SSD. The limitation is the USB 2 bus that everything goes through. When I tested with another board that has a native USB 3 port, the PiDrive jumped to 75MB/s to 80MB/s and the SSD 115MB/s to 125MB/s. (These results are why I *really* hope the Pi4B has USB 3.)

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: file read write speed test

Wed Jun 14, 2017 5:27 am

W. H. Heydt wrote:you need to do a "sync" command
thanks, ok, i will follow:
http://elinux.org/RPi_SD_cards#Performance

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: file read write speed test

Thu Jun 15, 2017 2:08 am

i used as suggested the
sync; "file copy"
for a file create by dd
for a file copy by rsync
but actually not very successful.
and my latest test shows that that was not the problem anyhow:

Code: Select all

[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=1024
1024+0 records in
1024+0 records out
524288000 bytes (524 MB) copied, 31.2519 s, 16.8 MB/s
[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=512
512+0 records in
512+0 records out
262144000 bytes (262 MB) copied, 14.604 s, 18.0 MB/s
[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=256
256+0 records in
256+0 records out
131072000 bytes (131 MB) copied, 3.902 s, 33.6 MB/s
[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=128
128+0 records in
128+0 records out
65536000 bytes (66 MB) copied, 0.297222 s, 220 MB/s
[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=64
64+0 records in
64+0 records out
32768000 bytes (33 MB) copied, 0.148824 s, 220 MB/s
[email protected]:~ $ sync; dd if=/dev/zero of=test.tmp bs=500K count=32
32+0 records in
32+0 records out
16384000 bytes (16 MB) copied, 0.0978845 s, 167 MB/s
[email protected]:~ $
all that MB/s numbers are just BS.

also the rsync command still shows 5 .. 10 times the speed as 2 years before.
i used to copy a >10MB file from SD to ram disk ( read speed ) and from ram disk to SD ( write speed )

now even if used with
sync; rsync -ahP "from" "to"

anyone has a trustable file copy speed test code?
run on latest RPI and OS with results for SD read write?

W. H. Heydt
Posts: 11064
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: file read write speed test

Thu Jun 15, 2017 3:37 am

Here are my notes on doing data transfer tests:

Code: Select all

Test Regime

As suggest by mikronauts, and with timing I constructed, the following tests were run:

#  Only report buffered read from hdparm
hdparm -tT <device>   

* Write speed
date; dd if=/dev/zero of=testfile bs=1M count=3072; sync; sync; date

# Read speed
date; dd if=testfile of=/dev/null bs=1M count=3072; sync; sync; date

# Copy speed
date; dd if=testfile of=testfile2 bs=1M count=3072; sync; sync; date

The “sync; sync” is to force disk activity completion within the time used to calculate the data rate.  Results are truncated to one place after the decimal point.  Times are, for the most part in the 60 secs. to 300 secs. Range.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: file read write speed test

Thu Jun 15, 2017 4:30 am

sorry i do not have a
[email protected]:~ $ hdparm
-bash: hdparm: command not found

Code: Select all

[email protected]:~ $ date; dd if=/dev/zero of=testfile bs=1M count=3072; sync; sync; dateThu 15 Jun 11:07:46 +07 2017
3072+0 records in
3072+0 records out
3221225472 bytes (3.2 GB) copied, 248.039 s, 13.0 MB/s
Thu 15 Jun 11:12:02 +07 2017
[email protected]:~ $ date; dd if=testfile of=/dev/null bs=1M count=3072; sync; sync; date
Thu 15 Jun 11:12:15 +07 2017
3072+0 records in
3072+0 records out
3221225472 bytes (3.2 GB) copied, 149.242 s, 21.6 MB/s
Thu 15 Jun 11:14:44 +07 2017
[email protected]:~ $ date; dd if=/dev/zero of=testfile bs=1K count=3072; sync; sync; date
Thu 15 Jun 11:15:00 +07 2017
3072+0 records in
3072+0 records out
3145728 bytes (3.1 MB) copied, 0.0340341 s, 92.4 MB/s
Thu 15 Jun 11:15:01 +07 2017
[email protected]:~ $ date; dd if=testfile of=/dev/null bs=1K count=3072; sync; sync; date
Thu 15 Jun 11:15:40 +07 2017
3072+0 records in
3072+0 records out
3145728 bytes (3.1 MB) copied, 0.0186005 s, 169 MB/s
Thu 15 Jun 11:15:40 +07 2017
[email protected]:~ $
so i used your 3GB file (bs=1M)
but also a 3MB file (bs=1K)
and all that not make me trust that results more as when using

Code: Select all

sync; dd if=/dev/zero of=test.tmp bs=500K count=1024
the MB/s reported by dd tool depends on file size, so its useless

and as i use a 32GB samsung evo
reporting with your command r: 22MB/s w: 13MB/s
that is too far from your reported r: 35MB/s w: 30MB/s
what was your SD card?

W. H. Heydt
Posts: 11064
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: file read write speed test

Thu Jun 15, 2017 5:09 am

If you deal with small amounts of data (like 3MB), it will all fit in memory. 3GB won't , so you are far more likely to measure MSD speed than memory speed.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: file read write speed test

Thu Jun 15, 2017 6:04 am

W. H. Heydt wrote:If you deal with small amounts of data (like 3MB), it will all fit in memory. 3GB won't , so you are far more likely to measure MSD speed than memory speed.
so if it all happens in memory, why i still see a reasonable speed difference between read and write?

again write test with your 3.2GB file (each 2 times):
2 sync after dd 15MB/s
1 sync prior dd 13MB/s
0 sync with dd 14MB/s

pls think again, the sync's after the dd might do a job, like finalizing the writing to disk,
but can never influence / correct the ?wrong? dd MB/s speed reporting..

an other thought, i like my RPI,
but i somehow doubt that it is 2 times as fast writing to SD card
as my win7 PC / USB2 / card reader / image write / at 7MB/s

Return to “Beginners”