Skip to content

Instantly share code, notes, and snippets.

@davlgd
Created March 10, 2020 09:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davlgd/5da3d36486a1bd59bc838638cb26f004 to your computer and use it in GitHub Desktop.
Save davlgd/5da3d36486a1bd59bc838638cb26f004 to your computer and use it in GitHub Desktop.
Raspberry Pi SD Card Speed Test files
# Use FIO to emulate the Apps Class A1 performance test.
# This isn't an exact benchmark as the card isn't in the state required by the
# specification, but is good enough as a sniff test.
#
[global]
ioengine=libaio
iodepth=4
size=64m
direct=1
end_fsync=1
directory=/var/tmp
filename=sd.test.file
[prepare-file]
rw=write
bs=512k
stonewall
[seq-write]
rw=write
bs=512k
stonewall
[rand-4k-write]
rw=randwrite
bs=4k
runtime=10
stonewall
[rand-4k-read]
rw=randread
bs=4k
runtime=10
stonewall
# execute with command $ fio --output-format=terse sd_bench.fio | cut -f 3,7,8,48,49 -d";" -
# testname, read bandwidth, read iops, write bandwidth, write iops
#!/bin/bash
#NAME=SD Card Speed Test
#DESC=Determines whether an SD card can read and write data fast enough to provide adequate performance.\n\nShould be run on a new or newly-formatted SD card.
for i in 1 2 3
do
echo "Run" $i
RES=$(fio --output-format=terse /usr/share/agnostics/sd_bench.fio | cut -f 3,7,8,48,49 -d";" -)
echo "$RES"
swri=$(echo "$RES" | head -n 2 | tail -n 1 | cut -d ";" -f 4)
rwri=$(echo "$RES" | head -n 3 | tail -n 1 | cut -d ";" -f 5)
rrea=$(echo "$RES" | head -n 4 | tail -n 1 | cut -d ";" -f 3)
pass=0
if [ "$swri" -lt 10000 ] ; then
echo "Sequential write speed $swri kb/s (target 10000) - FAIL"
echo "Note that sequential write speed declines over time as a card is used - your card may require reformatting"
pass=1
else
echo "Sequential write speed $swri kb/s (target 10000) - PASS"
fi
if [ "$rwri" -lt 500 ] ; then
echo "Random write speed $rwri IOPS (target 500) - FAIL"
pass=1
else
echo "Random write speed $rwri IOPS (target 500) - PASS"
fi
if [ "$rrea" -lt 1500 ] ; then
echo "Random read speed $rrea IOPS (target 1500) - FAIL"
pass=1
else
echo "Random read speed $rrea IOPS (target 1500) - PASS"
fi
rm -f /var/tmp/sd.test.file
if [ "$pass" -eq 0 ] ; then
return $pass
fi
done
return $pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment