Because of numerous caches from the CPU to the drive itself, using a simple method like this will not give precise results. However, it will let you see things like if a USB HDD is connected via USB 2 or USB 3, valuable if as common for me your PC is ≫ 1000 km away!
Note that you should instead of
bonnie++ or other proper benchmarking facility for accurate results, particularly for disk read benchmarks.
apt install bonnie++
For Cygwin, you would need to compile bonnie++ yourself currently.
USB HDD typical sequential write speed
USB 2 drives are hard-limited to no faster than 60 MB/s by the 480 Mb/s raw USB 2 speed. My experience is the real-life USB 2 HDD write sequential speed limit is more like 30-40 MB/s. A typical USB 3 HDD is limited by the magnetic hard drive speed with today’s hard drives, provided your chipset drivers aren’t messed up.
That’s actually why I use this simple test-I have had Windows fail to load the USB 3 drivers for an HDD, causing the drive to operate at USB 2 speeds, which you can easily detect with this test.
Test USB HDD sequential write speed
dd if=/dev/zero of=/tmp/junk bs=1G count=4 oflag=dsync
That command writes 4 GB sequentially. On a modern USB 3 HDD you should get 80-100 MB/s or more. If you get less than 60 MB/s you probably are using a USB 2 connection to your USB HDD.
Test USB HDD read speed
Despite what you might read on the Internet, I have not yet found any way to get a usable estimate of read speed with
dsync, etc. options don’t seem to work on read.