blob: d7f929d2be16f78ed01d90b1fa0bfe3d87743f12 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/sh
[ "$1" = -v ] && verbose=1
set -e
do_time() {
exec 3>&1
(time "$@") 2>&1 >&3 | grep . >&2
}
do_bench() {
tmpfile=$(mktemp)
trap 'rm -f "$tmpfile"' HUP INT QUIT TERM EXIT
[ -z "$verbose" ] || printf '%s compression:\n' "$1"
${verbose+do_time} "$@" -c <initramfs.img >"$tmpfile"
printf '%s size: %s bytes\n' "$1" "$(wc -c < "$tmpfile")"
printf '%s decompression:\n' "$1"
do_time "$1" -dc <"$tmpfile" >/dev/null
rm "$tmpfile"
trap '' EXIT
echo
}
if [ -e initramfs.img ] && [ "$(file -b initramfs.img)" != "ASCII cpio archive (SVR4 with no CRC)" ]; then
echo "warning: overwriting initramfs.img" >&2
compressor=cat ./make > initramfs.img
fi
do_bench gzip -9
do_bench bzip2 -9
do_bench lzma -9e --check=crc32
do_bench xz --check=crc32 --x86 --lzma2=preset=9e
do_bench lzop -9
do_bench lz4 --best --favor-decSpeed -l
|