Test USB 3.0 Device Speed

3

1

I've looked up the hdparm command, but all examples are for testing disks. Not sure if it can be used to test external usb devices (specifically a usb flash stick).

I'm using this code right now:

dd if=/dev/zero of=/media/storage/speed_test.txt bs=100K count=1k
sudo /sbin/sysctl -w vm.drop_caches=3
dd if=$/media/storage/speed_test.txt of=/dev/null bs=100K count=1k

What are the ranges of read and write speeds I should expect? I got ~900 MB/s for write and ~500 MB/s for read and I think the numbers are too high. Am I not clearing the cache correctly? What other commands I can use to test the speed?


Update:

Thanks to user427539’s answer and zloster’s comment, I now have a more accurate measurement of speeds. I'm testing with a 16GB USB flash stick and I'm writing and reading 1 GB of data. I got 22 MB/s for writing and 46 MB/s for reading. However, aren't such speeds too slow for a USB3 flash device? Why would the speed be so low?

tmp

Posted 2015-03-13T18:08:41.377

Reputation: 81

You should check the fsync options for dd when doing the writing test. More info here. Also use their setting for the sizes - at least 1GB.

– zloster – 2015-03-14T16:03:17.737

Answers

1

First that is only 100MB that you are writing. The disk and controller also have a cache that you aren't dropping, so you need a bigger test to make sure those caches aren't corrupting the results.

Bump that up at least 1GB. Maybe by changing to bs=1M. I normally test with 10GB just to be sure.

Then you need to make sure the data actually gets to disk, add "conv=fdatasync" at the end of the first line to do that.

As to normal speeds, USB2 devices / ports normally do between 10 and 20 MB/sec. USB3 devices should be between 50 and 150MB/sec. I'm very happy if I see a new device hit 120MB/sec. That's 7.2GB/min which is really fast.

But be aware a rotating disk reads/writes at the speed the platter spins under the head. Thus it you know the density (bits/inch) you can calculate the data speed:

throughput = radius * 2PI * density * RPM

The density you can't really control, but the RPM you can, the more RPMs the faster the raw speed.

Also, note that the radius of the platter changes based on where the head is. It might be about 1.75 inches on the outer track, but only 0.75 inches on the inner track. That means the drive will really slow down as you move from the outer track to the inner. Virgin drives typically have you writing to the outer track first, so you get much better speed at first. As the drive fills up it gets slower. I routinely see a 50% drop off in performance with a almost full drive.

user427539

Posted 2015-03-13T18:08:41.377

Reputation: 11

Is there a way to safely clear the controller cache? I'm actually testing with a USB flash stick. Is there a way to test a small one with, say, only 512 MB capacity ? – tmp – 2015-03-16T16:00:36.680

Well, you can be assured assured that a cold boot will have empty cache unless you have batteries in you case. (Some raid controllers really do have their own batteries). For the thumb drive, pulling it and reinserting is the only way I know to clear the cache. Seriously, those are the only 2 ways I know. – user427539 – 2015-03-17T19:49:41.310

RE: your new speeds. Thumb drives are very low cost devices. I've never benchmarked them, but I doubt your speeds are way off of reality. The devices are probably just slow. Benchmark an external USB3 rotating disk and you should see better speeds. – user427539 – 2015-03-17T19:55:12.357

sync before and after test command should give better results, still conv=fdatasync is good. – pbies – 2018-12-28T08:07:10.820