mt-polygon-simplification/scripts/bundle-size.sh
2019-07-14 20:37:26 +02:00

27 lines
769 B
Bash
Executable File

#!/usr/bin/env bash
# Prints the size of a file + gzipped size
human_print(){
while read B dummy; do
[ $B -lt 1024 ] && echo ${B} bytes && break
KB=$(((B+512)/1024))
[ $KB -lt 1024 ] && echo ${KB} kilobytes && break
MB=$(((KB+512)/1024))
[ $MB -lt 1024 ] && echo ${MB} megabytes && break
GB=$(((MB+512)/1024))
[ $GB -lt 1024 ] && echo ${GB} gigabytes && break
echo $(((GB+512)/1024)) terabytes
done
}
export FILE_NAME=$1
export UNCOMPRESSED_FILE_SIZE=`wc -c < $FILE_NAME`
export GZIPPED_FILE_SIZE=`gzip -c < $FILE_NAME | wc -c`
echo "Bundle size: $(echo $UNCOMPRESSED_FILE_SIZE | human_print)"
echo "gzipped size: $(echo $GZIPPED_FILE_SIZE | human_print)"
echo
echo "Machine readable:"
echo "BUNDLE_SIZE: $UNCOMPRESSED_FILE_SIZE,$GZIPPED_FILE_SIZE"