git subrepo pull (merge) --force deps/libchdr
[pcsx_rearmed.git] / deps / libchdr / deps / zstd-1.5.5 / contrib / linux-kernel / btrfs-extract-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 # silesia is a directory that can be downloaded from
9 # http://mattmahoney.net/dc/silesia.html
10 # ls -l silesia/
11 # total 203M
12 # -rwxr-xr-x 1 terrelln 9.8M Apr 12  2002 dickens
13 # -rwxr-xr-x 1 terrelln  49M May 31  2002 mozilla
14 # -rwxr-xr-x 1 terrelln 9.6M Mar 20  2003 mr
15 # -rwxr-xr-x 1 terrelln  32M Apr  2  2002 nci
16 # -rwxr-xr-x 1 terrelln 5.9M Jul  4  2002 ooffice
17 # -rwxr-xr-x 1 terrelln 9.7M Apr 11  2002 osdb
18 # -rwxr-xr-x 1 terrelln 6.4M Apr  2  2002 reymont
19 # -rwxr-xr-x 1 terrelln  21M Mar 25  2002 samba
20 # -rwxr-xr-x 1 terrelln 7.0M Mar 24  2002 sao
21 # -rwxr-xr-x 1 terrelln  40M Mar 25  2002 webster
22 # -rwxr-xr-x 1 terrelln 8.1M Apr  4  2002 x-ray
23 # -rwxr-xr-x 1 terrelln 5.1M Nov 30  2000 xml
24
25 # $HOME is on a ext4 filesystem
26 BENCHMARK_FILE="linux-4.11.6.tar"
27 BENCHMARK_DIR="$HOME/$BENCHMARK_FILE"
28
29 # Normalize the environment
30 sudo umount /mnt/btrfs 2> /dev/null > /dev/null || true
31 sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs
32 sudo rm -rf /mnt/btrfs/*
33 sync
34 sudo umount /mnt/btrfs
35 sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs
36
37 # Run the benchmark
38 echo "Copy"
39 time sh -c "sudo cp -r $BENCHMARK_DIR /mnt/btrfs/$BENCHMARK_FILE && sync"
40
41 echo "Approximate tarred compression ratio"
42 printf "%d / %d\n"                                                             \
43   $(df /mnt/btrfs --output=used -B 1 | tail -n 1)                              \
44   $(sudo du /mnt/btrfs -b -d 0 | tr '\t' '\n' | head -n 1);
45
46 # Unmount and remount to avoid any caching
47 sudo umount /mnt/btrfs
48 sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs
49
50 echo "Extract"
51 time sh -c "sudo tar -C /mnt/btrfs -xf /mnt/btrfs/$BENCHMARK_FILE && sync"
52
53 # Remove the tarball, leaving only the extracted data
54 sudo rm /mnt/btrfs/$BENCHMARK_FILE
55 # Unmount and remount to avoid any caching
56 sudo umount /mnt/btrfs
57 sudo mount -t btrfs $@ /dev/sda3 /mnt/btrfs
58
59 echo "Approximate extracted compression ratio"
60 printf "%d / %d\n"                                                             \
61   $(df /mnt/btrfs --output=used -B 1 | tail -n 1)                              \
62   $(sudo du /mnt/btrfs -b -d 0 | tr '\t' '\n' | head -n 1);
63
64 echo "Read"
65 time sudo tar -c /mnt/btrfs 2> /dev/null | wc -c > /dev/null
66
67 sudo rm -rf /mnt/btrfs/*
68 sudo umount /mnt/btrfs
69
70 # Run for each of -o compress-force={none, lzo, zlib, zstd} 5 times and take the
71 # min time and ratio.
72
73 # none
74 # copy: 0.981 s
75 # extract: 5.501 s
76 # read: 8.807 s
77 # tarball ratio: 0.97
78 # extracted ratio: 0.78
79
80 # lzo
81 # copy: 1.631 s
82 # extract: 8.458 s
83 # read: 8.585 s
84 # tarball ratio: 2.06
85 # extracted ratio: 1.38
86
87 # zlib
88 # copy: 7.750 s
89 # extract: 21.544 s
90 # read: 11.744 s
91 # tarball ratio : 3.40
92 # extracted ratio: 1.86
93
94 # zstd 1
95 # copy: 2.579 s
96 # extract: 11.479 s
97 # read: 9.389 s
98 # tarball ratio : 3.57
99 # extracted ratio: 1.85