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