"fio - flexible I/O tester" - man fio

This seems to work well in linux, but not so well in macOS.

Examples

Simple disk benchmark

mkdir temp  # somewhere on the disk you want to test
cd temp
fio
  --bs=4k \
  --end_fsync=1 \
  --iodepth=1 \
  --ioengine=posixaio \
  --name=random-write \
  --numjobs=1 \
  --runtime=60 \
  --rw=randwrite \
  --size=4g \
  --time_based

See also