Commit 2f6024bc authored by Adam Wujek's avatar Adam Wujek 💬

Add scripts to print table with sizes of binary for each commit since master

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent ce184a81
......@@ -16,3 +16,5 @@
.config.old
include/config
include/generated
size_db.txt
size_info.txt
......@@ -13,6 +13,21 @@ if [ $# -ne 0 ]; then
configs="$*"
fi
if ! [ -n "$size_db_file" ]; then
size_db_file=size_db.txt
echo "No file with size DB specified! Using default ($size_db_file)"
fi
if ! [ -n "$size_info_file" ]; then
size_info_file=size_info.txt
echo "No file with size info specified! Using default ($size_info_file)"
fi
export size_db_file
export size_info_file
rm -rf $size_info_file
for c in $configs; do
echo "##### Building with '$c'"
make -s clean; rm ppsi/.config; touch ppsi/.config
......@@ -20,6 +35,8 @@ for c in $configs; do
echo "Error in configuration (see $T)"
exit 1
fi
CONFIG_NAME=$c
export CONFIG_NAME
# Remove "# configuration written to .config" from output
make -s | grep -v '^#'
done
......@@ -30,3 +47,11 @@ cp $TW .config; rm $TW
cp $TP ppsi/.config; rm $TP
rm $T
./compare_size.sh
GIT_HASH=`git log --format=format:%H -1`
if [ -f "$size_db_file" ]; then
cat "$size_db_file" | grep -v $GIT_HASH > "$size_db_file".tmp
mv "$size_db_file".tmp "$size_db_file"
fi
cat "$size_info_file" >> "$size_db_file"
......@@ -155,6 +155,7 @@ $(OUTPUT).elf: $(LDS-y) $(AUTOCONF) gitmodules $(OUTPUT).o config.o
${CC} -o $@ revision.o config.o $(OUTPUT).o $(LDFLAGS)
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
$(SIZE) $@
./save_size.sh $(SIZE) $@
$(OUTPUT).o: $(OBJS)
$(LD) $(WRC-O-FLAGS-y) -r $(OBJS) -T bigobj.lds -o $@
......
#!/bin/bash
set -e
min_column_width=19
if ! [ -n "$size_info_file" ]; then
size_info_file=size_info.txt
echo "No file with size info specified! Using default ($size_info_file)"
fi
if ! [ -n "$size_db_file" ]; then
size_db_file=size_db.txt
echo "No file with size DB specified! Using default ($size_db_file)"
fi
if ! [ -f "$size_info_file" ]; then
echo "No file with build sizes ($size_info_file)! Exit."
exit 0
fi
if ! [ -f "$size_db_file" ]; then
echo "No DB file with build sizes ($size_db_file)! Exit."
exit 0
fi
# print the same string multiple times
repl() { printf -- "$1"'%.s' $(seq 1 $2); }
declare -A curr_size_array;
declare -A size_db_array;
declare -a commits_since_master;
GIT_HASH_CUR=`git rev-parse HEAD`
GIT_HASH_MASTER=`git rev-parse origin/master`
if ! [ -n "$GIT_HASH_CUR" ]; then
echo "Unable to get hash of a current commit"
exit 1
fi
if [ "$GIT_HASH_CUR" = "$GIT_HASH_MASTER" ]; then
echo "In master"
exit 0
fi
#echo "Read size info file"
while read git_hash config_name text data bss dec hex filename
do
if [ "$git_hash" = "$GIT_HASH_CUR" ]; then
curr_size_array[$config_name]=$dec
fi
done < "$size_info_file"
#echo "Read size db file"
while read git_hash config_name text data bss dec hex filename
do
#echo "$git_hash $config_name $dec"
size_db_array["$git_hash"_"$config_name"]="$dec"
done < "$size_db_file"
#print header
for i in "${!curr_size_array[@]}"
do
echo -n "+--"
# find minimum width
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
repl - $width
done
echo "+------------------------------------------------"
for i in "${!curr_size_array[@]}"
do
# find minimum width
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
printf "| %*s " $width $i
done
echo "|"
for i in "${!curr_size_array[@]}"
do
echo -n "+--"
# find minimum width
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
repl - $width
done
echo "+------------------------------------------------"
# print data
# print current size
for i in "${!curr_size_array[@]}"
do
# find minimum width
size=${curr_size_array[$i]}
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
printf "| %*s " $width "$size"
done
echo -n "| CURRENT "
# print hash and the title for current commit
git_current_commit=`git log --format=tformat:"%h %s" -1`
echo $git_current_commit
# print info abous previous commits
# pick ! as the separator
# tformat to get the newline after the last entry
git log --format=tformat:"!%H!%s" origin/master~1...HEAD~1 --graph | while IFS="!" read -r git_graph git_hash git_title
do
for i in "${!curr_size_array[@]}"
do
size=${size_db_array["$git_hash"_"$i"]}
if [ -z "$size" ]; then
print_buff=""
else
print_buff="($(($size-${curr_size_array[$i]}))) $size"
fi
# find minimum width
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
printf "| %*s " $width "$print_buff"
done
# print graph, hash and title
printf "| %-*s %.8s %s\n" 5 "$git_graph" "$git_hash" "$git_title"
done
for i in "${!curr_size_array[@]}"
do
echo -n "+--"
# find minimum width
if [ $min_column_width -gt ${#i} ]; then
width=$min_column_width
else
width=${#i}
fi
repl - $width
done
echo "+------------------------------------------------"
#!/bin/bash
set -e
if ! [ -n "$size_info_file" ]; then
echo "No file with size info specified!"
exit 0
fi
echo $1 $2 $CONFIG_NAME
# separate calling commands and filling DB
SIZES=`$1 $2 | grep $2`
GIT_HASH=`git log --format=format:%H -1`
echo -n "$GIT_HASH " >> "$size_info_file"
echo -n "$CONFIG_NAME ">> "$size_info_file"
echo $SIZES >> "$size_info_file"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment