mirror of
https://codeberg.org/shufflecake/shufflecake-c.git
synced 2026-01-08 12:05:50 -05:00
feat:Add working benchmarks LUKS and SFLC
The two scripts of the benchmark suite (for LUKS and for Shufflecake) are now complete and working.
This commit is contained in:
parent
6c5a912697
commit
79efccefe5
2 changed files with 76 additions and 20 deletions
|
|
@ -108,7 +108,7 @@ create_loop_device() {
|
|||
echo -e "${RED}Error: Impossible to generate file, $LOOP_FILENAME already exists${NC}"
|
||||
exit 1
|
||||
fi
|
||||
sudo dd if=/dev/zero of="$LOOP_FILENAME" bs=1M count=1024
|
||||
sudo dd if=/dev/zero of="$LOOP_FILENAME" bs=1M count=1024 > /dev/null
|
||||
echo "Writing of empty file complete. I will now try to attach it to a new loop device..." >&2
|
||||
LOOP_DEVICE=$(sudo losetup -f --show "$LOOP_FILENAME")
|
||||
echo "Successfully created loop device $LOOP_DEVICE" >&2
|
||||
|
|
@ -143,19 +143,58 @@ confirm() {
|
|||
# Benchmarks
|
||||
benchmark() {
|
||||
|
||||
LUKSVOLUME=""
|
||||
LUKSVOLUME="luks-test"
|
||||
MNTPOINT=""
|
||||
echo -e "${GREEN}Starting benchmark for LUKS/dm-crypt.${NC}"
|
||||
bpx
|
||||
# TODO
|
||||
bpx
|
||||
#end
|
||||
|
||||
PASSPHRASE="mypassword"
|
||||
echo "Starting benchmark for LUKS/dm-crypt."
|
||||
echo "Initializing block device $BLOCK_DEVICE as a LUKS volume..."
|
||||
etime=$( (time echo -n "$PASSPHRASE" | cryptsetup --batch-mode --cipher aes-xts-plain64 luksFormat $BLOCK_DEVICE - > /dev/null) 2>&1 )
|
||||
echo -e "${GREEN}Action luksFormat took $etime seconds.${NC}"
|
||||
echo "LUKS device initialized. Opening encrypted volume..."
|
||||
etime=$( (time echo -n "$PASSPHRASE" | cryptsetup luksOpen $BLOCK_DEVICE $LUKSVOLUME - > /dev/null) 2>&1 )
|
||||
echo -e "${GREEN}Action luksOpen took $etime seconds.${NC}"
|
||||
echo "LUKS volume opened as /dev/mapper/$LUKSVOLUME. Formatting with ext4..."
|
||||
# format with ext4, but mute output (too verbose)
|
||||
mkfs.ext4 /dev/mapper/$LUKSVOLUME > /dev/null
|
||||
echo "Volume /dev/mapper/$SFLCVOLUME formatted. Mounting that..."
|
||||
# assign and create MNTPOINT
|
||||
MNTPOINT=$(realpath "./luks_mnt")
|
||||
mkdir $MNTPOINT
|
||||
# mount
|
||||
mount /dev/mapper/$LUKSVOLUME $MNTPOINT
|
||||
echo "Volume mounted at $MNTPOINT. Starting fio tests..."
|
||||
# TESTS HERE
|
||||
# test 01: random read
|
||||
echo "Test 01: random read with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-r-rnd --ioengine=libaio --iodepth=32 --rw=randread --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, read_iops: .read.iops, read_bw: .read.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 02: random write
|
||||
echo "Test 02: random write with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-w-rnd --ioengine=libaio --iodepth=32 --rw=randwrite --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, write_iops: .write.iops, write_bw: .write.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 03: sequential read
|
||||
echo "Test 03: sequential read with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-r-seq --ioengine=libaio --iodepth=32 --rw=read --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, read_iops: .read.iops, read_bw: .read.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 04: sequential write
|
||||
echo "Test 04: sequential write with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-w-seq --ioengine=libaio --iodepth=32 --rw=write --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, write_iops: .write.iops, write_bw: .write.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# END TESTS
|
||||
echo "LUKS/dm-crypt fio tests ended. Unmounting volume."
|
||||
# unmount
|
||||
umount $MNTPOINT
|
||||
rmdir $MNTPOINT
|
||||
echo "Volume unmounted. Closing LUKS device..."
|
||||
# close
|
||||
etime=$( (time cryptsetup luksClose $LUKSVOLUME > /dev/null) 2>&1 )
|
||||
echo -e "${GREEN}Action close took $etime seconds.${NC}"
|
||||
#end
|
||||
}
|
||||
|
||||
# Clean up
|
||||
cleanup() {
|
||||
echo -e "${GREEN}Exiting and cleaning...${NC}"
|
||||
echo "Exiting and cleaning..."
|
||||
# TODO clean other stuff if necessary
|
||||
if [[ -n $LOOP_DEVICE ]]; then
|
||||
echo "Detaching $LOOP_DEVICE"
|
||||
|
|
@ -192,8 +231,11 @@ esac
|
|||
|
||||
check_sudo
|
||||
|
||||
echo "Checking that cryptsetup is installed"
|
||||
# TODO
|
||||
if ! which cryptsetup >/dev/null; then
|
||||
echo -e "${RED}ERROR: cryptsetup not found, please install it.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " "
|
||||
|
||||
|
||||
|
|
@ -205,7 +247,7 @@ case "$1" in
|
|||
|
||||
echo "Now you will be asked to enter the path for a block device to be used for the "
|
||||
echo "benchmarks (all content will be erased). If no path is provided (default"
|
||||
echo "choice), then the script will create a new 1 GiB in the current directory and "
|
||||
echo "choice), then the script will create a 1 GiB file in the current directory and "
|
||||
echo "use it to back a loop device instead, then the file will be removed at the end."
|
||||
echo " "
|
||||
echo -n "Please enter the path for a block device (default: none): "
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ create_loop_device() {
|
|||
echo -e "${RED}Error: Impossible to generate file, $LOOP_FILENAME already exists${NC}"
|
||||
exit 1
|
||||
fi
|
||||
sudo dd if=/dev/zero of="$LOOP_FILENAME" bs=1M count=1024
|
||||
sudo dd if=/dev/zero of="$LOOP_FILENAME" bs=1M count=1024 > /dev/null
|
||||
echo "Writing of empty file complete. I will now try to attach it to a new loop device..." >&2
|
||||
LOOP_DEVICE=$(sudo losetup -f --show "$LOOP_FILENAME")
|
||||
echo "Successfully created loop device $LOOP_DEVICE" >&2
|
||||
|
|
@ -243,7 +243,7 @@ benchmark() {
|
|||
|
||||
SFLCVOLUME=""
|
||||
MNTPOINT=""
|
||||
echo -e "${GREEN}Starting benchmark for Shufflecake.${NC}"
|
||||
echo -e "Starting benchmark for Shufflecake."
|
||||
echo "Initializing block device $BLOCK_DEVICE with two Shufflecake volumes (--skip-randfill)..."
|
||||
etime=$( (time echo -e "passwd1\npasswd2" | $SFLCNAME --skip-randfill -n 2 init $BLOCK_DEVICE > /dev/null) 2>&1 )
|
||||
echo -e "${GREEN}Action init took $etime seconds.${NC}"
|
||||
|
|
@ -262,13 +262,27 @@ benchmark() {
|
|||
# mount
|
||||
mount $SFLCVOLUME $MNTPOINT
|
||||
echo "Volume mounted at $MNTPOINT. Starting fio tests..."
|
||||
bpx
|
||||
# TESTS HERE
|
||||
fio --name=test --ioengine=libaio --iodepth=32 --rw=randrw --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile
|
||||
# test 01: random read
|
||||
echo "Test 01: random read with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-r-rnd --ioengine=libaio --iodepth=32 --rw=randread --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, read_iops: .read.iops, read_bw: .read.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 02: random write
|
||||
echo "Test 02: random write with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-w-rnd --ioengine=libaio --iodepth=32 --rw=randwrite --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, write_iops: .write.iops, write_bw: .write.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 03: sequential read
|
||||
echo "Test 03: sequential read with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-r-seq --ioengine=libaio --iodepth=32 --rw=read --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, read_iops: .read.iops, read_bw: .read.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# test 04: sequential write
|
||||
echo "Test 04: sequential write with a queue of 32 4kiB blocks on a file (20s)..."
|
||||
OUTPUT=$(fio --name=luks-w-seq --ioengine=libaio --iodepth=32 --rw=write --bs=4k --numjobs=1 --size=500M --runtime=20 --time_based --end_fsync=1 --filename=$MNTPOINT/testfile --output-format=json | jq '.jobs[] | {name: .jobname, write_iops: .write.iops, write_bw: .write.bw}')
|
||||
echo -e "${GREEN}${OUTPUT}${NC}"
|
||||
# END TESTS
|
||||
echo "Shufflecake fio tests ended. Unmounting volume."
|
||||
bpx
|
||||
# unmount
|
||||
umount $SFLCVOLUME $MNTPOINT
|
||||
umount $MNTPOINT
|
||||
rmdir $MNTPOINT
|
||||
echo "Volume unmounted. Closing Shufflecake device..."
|
||||
# close
|
||||
|
|
@ -280,7 +294,7 @@ benchmark() {
|
|||
|
||||
# Clean up
|
||||
cleanup() {
|
||||
echo -e "${GREEN}Exiting and cleaning...${NC}"
|
||||
echo "Exiting and cleaning..."
|
||||
# TODO clean other stuff if necessary
|
||||
if [[ -n $LOOP_DEVICE ]]; then
|
||||
echo "Detaching $LOOP_DEVICE"
|
||||
|
|
@ -335,7 +349,7 @@ case "$1" in
|
|||
|
||||
echo "Now you will be asked to enter the path for a block device to be used for the "
|
||||
echo "benchmarks (all content will be erased). If no path is provided (default"
|
||||
echo "choice), then the script will create a new 1 GiB in the current directory and "
|
||||
echo "choice), then the script will create a 1 GiB file in the current directory and "
|
||||
echo "use it to back a loop device instead, then the file will be removed at the end."
|
||||
echo " "
|
||||
echo -n "Please enter the path for a block device (default: none): "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue