Blog   About  Archives

Checking Disk Speeds on your Mac

With a new computer, one of the things that becomes obvious is the gain in overall performance. One of the aspects that I always find fascinating is Disk Speed. Especially with these new PCIe based SSDs that these new MacBook Airs ship with. Of course, there are very decent Disk Speed Checkers out there for mac - BlackMagic Disk Speed Test by BlackMagic Design.

However, I wanted to see if this could be done via a quick script directly in a reliable manner without any 3rd party utilities. A quick google search got me a script from a UK based Mac Repair Specialist. With the help of some other community forums I was able to tweak the script to make it run a tad faster and more accurately account for nuances related to my mac.

To start off, I created a file at a location of my choice. I named it diskspeed and placed it in my ~/ directory. Second order of business, I wanted to ensure it’s executable, and

chmod +x diskspeed

allowed me to do just that.

The hierarchy of logic for this bash script looked like this-

This is how my diskspeed file looked like after I had made my changes


echo "---------------------"
echo "Write Test Running. Please Wait..." 
write=$(dd if=/dev/zero bs=2048k of=/Users/ramawat/Artifacts/Helper/tstfile count=8192 2>&1 | awk '/sec/ {print $1 / $5 / 1048576, "MB/sec" }')
sudo purge
echo ""
echo "Read Test Running. Please Wait..."
read=$(dd if=/Users/ramawat/Artifacts/Helper/tstfile bs=2048k of=/dev/null count=8192 2>&1 | awk '/sec/ {print $1 / $5 / 1048576, "MB/sec" }')
echo ""
echo "Read Speed is: $read"
echo "Write Speed is: $write"
echo "---------------------"
echo "Cleaning up. Please Wait..."
sudo purge
rm -rf /Users/ramawat/Artifacts/Helper/tstfile
echo "Test File Deleted"
echo ""
exit 0

Some points to note:

Written on Mar 21, 2019.