How to benchmark Disk performance on Linux - LinuxConfig.org

Just bought the latest and greatest - and especially fastest - SDD? Or upgraded your phone's microSD memory card? Before you start using your shiny new hardware, you may want to run a performance check against the drive. Is the write and read speed up to manufacturer's specifications? How does your performance compare with that of others? Is that 1TB flash drive you bought on an auction site from China really as fast as the listing said it was? Let us find out!
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-benchmark-disk-performance-on-linux

Thanks @Roel_Van_de_Paar. I bought an inexpensive 128G mini SD card from China. No surprise that it failed the first check of just dumping some files into it; just disappointment. So I found your article on doing some better checking. Here are the results (yes, it is only 4Gi with modified interface):

$ lsblk | grep sde
sde 8:64 1 125G 0 disk
└─sde1 8:65 1 125G 0 part /media/rigtig/test
# where size result in Gibibyte (1 Gibibyte = 1073700000 bytes)

$ hdparm -Ttv /dev/sde1

/dev/sde1:
SG_IO: bad/missing sense data, sb: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
multcount = 0 (off)
readonly = 0 (off)
readahead = 256 (on)
geometry = 16317/255/63, sectors = 262144000, start = 2048
Timing cached reads: 9782 MB in 1.99 seconds = 4904.39 MB/sec
Timing buffered disk reads: 42 MB in 3.08 seconds = 13.65 MB/sec

$ sudo su
# cd /tmp
# mkdir mnt
# mount /dev/sde1 ./mnt
# linux-beginners-newbie sync
# echo 3 > /proc/sys/vm/drop_caches
# dd if=/dev/zero of=/tmp/mnt/temp oflag=direct bs=128k count=1G
dd: error writing ‘/tmp/mnt/temp’: File too large
32768+0 records in
32767+0 records out
4294967295 bytes (4.3 GB, 4.0 GiB) copied, 451.074 s, 9.5 MB/s

Thank you very much for this post. I am particularly interested in the suggested oflag=direct flag.

When I do a dd write test with random data to my internal M2 ssd drive, I see a 4x-5x difference in speed with and without the oflag=direct flag. And more importantly this big difference varies between drives.

So what is the effective real use speed when the ssd is used for running an os (that is, it is not a pure data storage medium), is it closer to that lower number indicated with the oflag=direct test or to the one without it?