-
-
Save terrelln/51ed3c9da6f94d613c01fcdae60567e8 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
# !/bin/sh | |
set -e | |
# $HOME is on a ext4 filesystem | |
BENCHMARK_DIR=/tmp/silesia | |
N=10 | |
# Create the BtrFS filesystem | |
rm -f /tmp/disk | |
losetup -D | |
umount /mnt/test ||: | |
dd if=/dev/zero of=/tmp/disk bs=4096 seek=1048575 count=1 | |
mkfs.btrfs -msingle /tmp/disk | |
losetup -f /tmp/disk | |
sleep 1 # yay udev races | |
# Mount the filesystem | |
mount -onoatime,compress-force=$1 /dev/loop0 /mnt/test | |
echo "Benchmarking $1" | |
# Run the benchmark | |
echo "Compression" | |
time sh -c "for i in \$(seq $N); do cp -r $BENCHMARK_DIR /mnt/test/\$i; done; sync" | |
# Unmount and remount to avoid any caching | |
umount /mnt/test | |
losetup -D | |
losetup -f /tmp/disk | |
mount -onoatime,compress=$1 /dev/loop0 /mnt/test | |
echo "Approximate compression ratio" | |
# Should probably switch to compsize | |
printf "%d / %d\n" \ | |
$(df /mnt/test --output=used -B 1 | tail -n 1) \ | |
$(du /mnt/test -b -d 0 | tr '\t' '\n' | head -n 1); | |
# Unmount and remount to avoid any caching | |
umount /mnt/test | |
losetup -D | |
losetup -f /tmp/disk | |
mount -onoatime,compress-force=$1 /dev/loop0 /mnt/test | |
echo "Decompression" | |
time tar -c /mnt/test | wc -c | |
# Cleanup | |
losetup -D | |
umount /mnt/test | |
rm -f /tmp/disk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment