Use hdparm to Benchmark Disk in Linux

I use this often in the vm-land to test VMFS stores/LUN performance of new VMs I setup and I also use a few other benchmark tools to monitor how performance is impacted over the course of time.

root@nitrous:~# hdparm -Tt /dev/sda
/dev/sda:
 Timing cached reads:   12420 MB in  2.00 seconds = 6217.17 MB/sec
 Timing buffered disk reads: 584 MB in  3.00 seconds = 194.43 MB/sec

The -T option: The speed of reading through the buffer cache to the disk without any prior caching of data.
The -t option: The speed of reading directly from the Linux buffer cache without disk access.
That measured sequential access, now lets look at random seeks.

Seeker (http://www.linuxinsight.com/how_fast_is_your_disk.html)

Local download: https://techish.net/wp-content/uploads/2022/06/seeker.c

This is with defaults

root@nitrous:~# gcc -O2 seeker.c -o seeker
root@nitrous:~# ./seeker /dev/sda
Seeker v2.0, 2007-01-15, http://www.linuxinsight.com/how_fast_is_your_disk.html
Benchmarking /dev/sda [51200MB], wait 30 seconds.............................
Results: 278 seeks/second, 3.58 ms random access time

SeekMark (http://learnitwithme.com/?page_id=267)

Local download: https://techish.net/wp-content/uploads/2022/06/seekmark-0.3.c

This is with defaults (Single thread, 0-5000 random seeks on /dev/sda, 512 bytes)

root@nitrous:~# ./seekmark -f/dev/sda
READ benchmarking against /dev/sda 51200 MB
threads to spawn: 1
seeks per thread: 5000
io size in bytes: 512
Spawning worker 0 to do 5000 seeks
thread 0 completed, time: 15.92, 314.09 seeks/sec, 3.2ms per request
total time: 15.92, time per READ request(ms): 3.184
314.09 total seeks per sec, 314.09 READ seeks per sec per thread

This is with 10 threads, 0-5000 random seeks on /dev/sda

root@nitrous:~# gcc -o seekmark -lpthread seekmark-0.9.c
root@nitrous:~# ./seekmark -f/dev/sda -t10
READ benchmarking against /dev/sda 51200 MB
threads to spawn: 10
seeks per thread: 5000
io size in bytes: 512
Spawning worker 0 to do 5000 seeks
Spawning worker 1 to do 5000 seeks
Spawning worker 2 to do 5000 seeks
Spawning worker 3 to do 5000 seeks
Spawning worker 4 to do 5000 seeks
Spawning worker 5 to do 5000 seeks
Spawning worker 6 to do 5000 seeks
Spawning worker 7 to do 5000 seeks
Spawning worker 8 to do 5000 seeks
Spawning worker 9 to do 5000 seeks
thread 4 completed, time: 142.17, 35.17 seeks/sec, 28.4ms per request
thread 7 completed, time: 144.52, 34.60 seeks/sec, 28.9ms per request
thread 2 completed, time: 152.03, 32.89 seeks/sec, 30.4ms per request
thread 9 completed, time: 152.75, 32.73 seeks/sec, 30.5ms per request
thread 8 completed, time: 152.88, 32.70 seeks/sec, 30.6ms per request
thread 5 completed, time: 153.19, 32.64 seeks/sec, 30.6ms per request
thread 3 completed, time: 153.47, 32.58 seeks/sec, 30.7ms per request
thread 6 completed, time: 155.04, 32.25 seeks/sec, 31.0ms per request
thread 1 completed, time: 155.79, 32.10 seeks/sec, 31.2ms per request
thread 0 completed, time: 156.64, 31.92 seeks/sec, 31.3ms per request
total time: 156.64, time per READ request(ms): 3.133
319.21 total seeks per sec, 31.92 READ seeks per sec per thread