summaryrefslogtreecommitdiff
path: root/comp_bench
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-04-23 20:40:06 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-04-23 20:40:06 -0400
commit6d7f30baa5c8c4d5ca9b5ec8f07f0ae0c510b710 (patch)
treee7ed8ecbb5dd78d8c15b2b8d45aff2f9b779e1a7 /comp_bench
parent7739d1863cb6ea5de819e1ae1c1ee10e8109d32b (diff)
downloadminitramfs-6d7f30baa5c8c4d5ca9b5ec8f07f0ae0c510b710.tar.xz
minitramfs-6d7f30baa5c8c4d5ca9b5ec8f07f0ae0c510b710.zip
fixes, updates, LICENSE file
Diffstat (limited to 'comp_bench')
-rwxr-xr-xcomp_bench21
1 files changed, 17 insertions, 4 deletions
diff --git a/comp_bench b/comp_bench
index 01387da..d7f929d 100755
--- a/comp_bench
+++ b/comp_bench
@@ -1,18 +1,31 @@
#!/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"' EXIT
- compressor=cat outfile=/proc/self/fd/1 ./make | "$@" -c < initramfs.img > "$tmpfile"
- printf '%s: %s bytes\n' "$1" "$(wc -c < "$tmpfile")"
- time $1 -dc < "$tmpfile" >/dev/null
+ 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