about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xpatch/bdiff.sh24
1 files changed, 20 insertions, 4 deletions
diff --git a/patch/bdiff.sh b/patch/bdiff.sh
index 33d109bd8cbb..1515319738d3 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