Skip to content

Commit

Permalink
Benchmark FreeBSD/geli devices
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Kujau <[email protected]>
  • Loading branch information
ckujau committed Jun 9, 2020
1 parent 1d7972c commit 46d52e2
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions benchmarks/geli_benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/sh
#
# (c)2019 Christian Kujau <[email protected]>
# Read-only Benchmark for FreeBSD/geli.
#
CIPHERS="aes-xts aes-cbc blowfish-cbc camellia-cbc 3des-cbc" # See geli(8)
PROG=$(basename $0)
set -e

_help() {
echo "Usage: ${PROG} [devicename] [size(MB)] [runs]"
echo " ${PROG} report [out.txt]"
echo ""
echo "Example: ${PROG} ada0p2 5 | tee out.txt"
echo " ${PROG} report out.txt"
}

_benchmark() {
DEV="$1"
SIZE="$2"
NUM="$3"


# RAW
for i in $(seq 1 "${NUM}"); do
printf "MODE: raw I: $i\t"
dd if=/dev/"${DEV}" of=/dev/null bs=1k count="${SIZE}"k conv=sync 2>&1 | grep bytes
done

# ENCRYPTED
for c in ${CIPHERS}; do
geli onetime -e "${c}" /dev/"${DEV}"

# Repeat NUM times...
for i in $(seq 1 "${NUM}"); do
printf "MODE: ${c} I: $i\t"
dd if=/dev/"${DEV}.eli" of=/dev/null bs=1k count="${SIZE}"k conv=sync 2>&1 | grep bytes
done

geli detach /dev/"${DEV}.eli"
done
}

case $1 in
report)
if [ -f "$2" ]; then
for c in $(awk '/MODE:/ {print $2}' "$2" | uniq); do
NUM=$(grep -c "MODE: $c" "$2")
printf "${c} \t"
awk "/MODE: ${c}/ {print \$9, \$11, \$2}" "$2" | sed 's/(//' | \
awk "{time+=\$1} {speed+=\$2} END {print time/${NUM}, \"sec /\", speed/${NUM}/1024/1024, \"MB/s\"}"
done
else
_help
fi
;;

*)
if [ -c /dev/"$1" ] && [ "$2" -gt 0 ] && [ "$3" -gt 0 ]; then
_benchmark "${1}" "${2}" "${3}"
else
_help
fi
;;
esac

0 comments on commit 46d52e2

Please sign in to comment.