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