I wanted to perform exactly this same test on a bunch of USB drives myself a couple or 3 years ago.....the more so, given that most of my 'fleet' of drives (got dozens and dozens of 'em!) are getting to be USB 3.0, 3.1, or 3.2 Gen1.
I wanted to do this with a GUI, though I knew I'd be happy enough to have the readout via terminal. So; research showed that amongst its many other attributes,
dd was capable of writing/reading random data to/from a file. Moreover, the parameters of this file (and the individual operations) could be separately specified; block size for both read & write operations, along with file size required, etc.
And so,
DriveSpeed! was born.
~~~~~~~~~~~~~~~
A sample 'write' operation looks like this (and needs running first in order to create the 'test' file). This is for 2Mb write block sizes and a 4 Gb test file:-
Code:
rxvt -title ' ~ Drive write speed - 2Mb block.....' -background '#ffff80' -geometry '80x6' rxvt -hold ls -e dd if=/dev/zero of=$HERE/testfile bs=2M status=progress oflag=sync count=2048
....and a sample 'read' operation would look like this; here it's for a 4 Mb block size on the same 4 Gb test file:-
Code:
rxvt -title ' ~ Drive read speed - 4Mb block.......' -background '#ffff80' -geometry '80x6' rxvt -hold ls -e dd if=$HERE/testfile of=/dev/null bs=4M status=progress oflag=sync
The 'status=progress' flag gives a real-time readout of progress as the operation executes; not just amount read/written, but time elapsed and eventual read/write 'speed', calculated in Mb/sec.
~~~~~~~~~~~~~~~~~
The GUI was written with YAD. The order of button operations are numbered to make it more obvious to the user; the read block size, write block size & test file size are all pre-selected before running the respective operations.
The whole thing is built as a 'ROX-app'; a unique function of the ROX-filer FM that lets you execute the entire contents of a ROX directory by simply single-clicking on that directory (very similar to how an AppImage functions). It's around 280 kb in size, and the entire thing is designed to be 'disposable'; you keep a master copy somewhere safe, and when you want to speed-test any given drive, simply drag'n'drop a copy onto the 'root' of that drive. You run the operations, then shut it down.....and simply delete the whole thing.
Works really well!
Mike.