squashfs-benchmark.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # !/bin/sh
  2. set -e
  3. # Benchmarks run on a Ubuntu 14.04 VM with 2 cores and 4 GiB of RAM.
  4. # The VM is running on a Macbook Pro with a 3.1 GHz Intel Core i7 processor and
  5. # 16 GB of RAM and an SSD.
  6. # $BENCHMARK_DIR is generated with the following commands, from the Ubuntu image
  7. # ubuntu-16.10-desktop-amd64.iso.
  8. # > mkdir mnt
  9. # > sudo mount -o loop ubuntu-16.10-desktop-amd64.iso mnt
  10. # > cp mnt/casper/filesystem.squashfs .
  11. # > sudo unsquashfs filesystem.squashfs
  12. # $HOME is on a ext4 filesystem
  13. BENCHMARK_DIR="$HOME/squashfs-root/"
  14. BENCHMARK_FS="$HOME/filesystem.squashfs"
  15. # Normalize the environment
  16. sudo rm -f $BENCHMARK_FS 2> /dev/null > /dev/null || true
  17. sudo umount /mnt/squashfs 2> /dev/null > /dev/null || true
  18. # Run the benchmark
  19. echo "Compression"
  20. echo "sudo mksquashfs $BENCHMARK_DIR $BENCHMARK_FS $@"
  21. time sudo mksquashfs $BENCHMARK_DIR $BENCHMARK_FS $@ 2> /dev/null > /dev/null
  22. echo "Approximate compression ratio"
  23. printf "%d / %d\n" \
  24. $(sudo du -sx --block-size=1 $BENCHMARK_DIR | cut -f1) \
  25. $(sudo du -sx --block-size=1 $BENCHMARK_FS | cut -f1);
  26. # Mount the filesystem
  27. sudo mount -t squashfs $BENCHMARK_FS /mnt/squashfs
  28. echo "Decompression"
  29. time sudo tar -c /mnt/squashfs 2> /dev/null | wc -c > /dev/null
  30. sudo umount /mnt/squashfs