From d1813a10c682afca756250fbb6133bb0853e0054 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 21 Jan 2024 13:17:54 +0100 Subject: BLoC min tree size parameter optimizer --- optimize | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 optimize (limited to 'optimize') diff --git a/optimize b/optimize new file mode 100755 index 0000000..a70b936 --- /dev/null +++ b/optimize @@ -0,0 +1,36 @@ +#!/bin/bash + +# finds optimal --min-size value for bloc + +target="blc" + +# remove files on exit +trap 'rm -f "$file".bloc "$file".bloc."$target"; exit 0' EXIT SIGINT SIGTERM + +if [ $# -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +file=$1 + +function try { + bloc --from-blc -i "$file" -o "$file".bloc -m "$1" + blocade -i "$file".bloc -t "$target" -o "$file".bloc."$target" + size="$(stat -c %s "$file".bloc."$target")" +} + +low=5 +high=100000 +best=100000000000000000 +while [ $low -lt $high ]; do + mid=$(((low + high) / 2)) + try $mid + echo "$mid: $size" + if [ "$size" -le $best ]; then + best=$size + high=$((mid - 1)) + else + low=$((mid + 1)) + fi +done -- cgit v1.2.3