From 6d7f30baa5c8c4d5ca9b5ec8f07f0ae0c510b710 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Thu, 23 Apr 2020 20:40:06 -0400 Subject: fixes, updates, LICENSE file --- comp_bench | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'comp_bench') 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 "$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 -- cgit v1.2.3-70-g09d2