summaryrefslogtreecommitdiff
path: root/comp_bench
diff options
context:
space:
mode:
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