From 71926ee18803071e64754465faf3d57d6dc9bbda Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 29 Nov 2004 21:04:28 +0000 Subject: [PATCH] * Print out statistics comparing our performance to bzip2. --- patch/bdiff.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/patch/bdiff.sh b/patch/bdiff.sh index 33d109bd8..151531973 100755 --- a/patch/bdiff.sh +++ b/patch/bdiff.sh @@ -1,6 +1,7 @@ #! /bin/sh -e -DIFF=/home/eelco/Dev/nix/zdelta-2.1/zdc +#DIFF=/home/eelco/Dev/nix/zdelta-2.1/zdc +DIFF=/home/eelco/Dev/nix/bsdiff-4.2/bsdiff srcA=$1 srcB=$2 @@ -12,13 +13,28 @@ fi (cd $srcB && find . -type f) | while read fn; do - echo "$fn" >&2 - if test -f "$srcA/$fn"; then echo "FILE DELTA FOR $fn" - $DIFF "$srcA/$fn" "$srcB/$fn" + TMPFILE=/tmp/__bsdiff + $DIFF "$srcA/$fn" "$srcB/$fn" $TMPFILE + cat $TMPFILE + + diffSize=$(stat -c '%s' $TMPFILE) + + # For comparison. + bzipSize=$(bzip2 < "$srcB/$fn" | wc -m) + + gain=$(echo "scale=2; ($diffSize - $bzipSize) / $bzipSize * 100" | bc) + + ouch=$(if test "${gain:0:1}" != "-"; then echo "!"; fi) + + printf "%7.2f %1s %10d %10d %s\n" \ + "$gain" "$ouch" "$diffSize" "$bzipSize" "$fn" >&2 +# echo "$fn -> $diffSize $bzipSize ==> $gain $ouch" >&2 + + rm $TMPFILE else