Created
July 6, 2021 14:48
-
-
Save xanoni/eabae6ef5c8cf4ffaccb9df9ddbd4929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env -S bash -e | |
drive="/dev/sda" | |
if ! [ -z ${1} ]; then | |
drive=${1} | |
fi | |
function benchmark_cryptsetup { | |
local num_runs=${1} | |
for i in $(seq ${num_runs}); do | |
echo -en "\n> cryptsetup benchmark $i/${num_runs}:\n\n" | |
for cipher in "xchacha12,aes-adiantum-plain64" "xchacha20,aes-adiantum-plain64" "aes-xts-plain64"; do | |
cryptsetup benchmark --cipher="${cipher}"; | |
done | |
done | |
echo -en "\n> cryptsetup benchmark done!\n\n\n" | |
} | |
function benchmark_dd { | |
local bs=${1} | |
local count=${2} | |
local num_runs=${3} | |
for i in $(seq ${num_runs}); do | |
echo -en "\n> dd benchmark ${i}/${num_runs} (bs=${bs}):\n" | |
echo -en "\nwrite test:\n" | |
sudo sync | |
sudo bash -c "echo '3' > /proc/sys/vm/drop_caches" | |
sudo dd if=/dev/zero of=deleteme.img bs=${bs} count=${count} conv=fdatasync status=progress 2>&1 | |
echo -en "\nread test:\n" | |
sudo bash -c "echo '3' > /proc/sys/vm/drop_caches" | |
sudo dd if=deleteme.img of=/dev/null bs=${bs} status=progress 2>&1 | |
sudo rm deleteme.img | |
done | |
echo -en "\n> dd benchmark done!\n\n\n" | |
} | |
function benchmark_hdparm { | |
local bench_drive=${1} | |
local num_runs=${2} | |
for i in $(seq ${num_runs}); do | |
echo -en "\n> hdparm benchmark ${i}/${num_runs} (${bench_drive}):\n\n" | |
sudo hdparm -Tt ${bench_drive} 2>&1 | |
done | |
echo -en "\n> hdparm benchmark done!\n\n" | |
} | |
# Let's go | |
echo -en "\nPlease make sure your working dir is on the drive to be benchmarked!\n\n" | |
#benchmark_cryptsetup 2 | |
benchmark_dd 1M $((1024*5)) 1 | |
benchmark_dd 64k $((1024*48)) 2 | |
benchmark_dd 4k $((1024*512)) 2 | |
benchmark_hdparm ${drive} 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment