Skip to content

Commit

Permalink
remove percentage, small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
adomani committed May 18, 2024
1 parent 56456bc commit 5730c66
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions scripts/mathlib_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ date=${hashAndDate/#* /}
## 'x files changed, y insertions(+), z deletions(-)'
gdiff="$(git diff --shortstat "${oldCommit}"...${currentCommit})"

## percentage breakdown of changes
percent="$(printf '|%%|Folder|\n|-:|:-|\n'; git diff --dirstat "${oldCommit}"...HEAD |
sed 's=^ *=|=; s= *=|`=g; s=$=`|='
#awk 'BEGIN{FS=" "; OFS="|"} {for(i=1; i<=NF; i++){printf $i}}'
)"

printf -v today '%(%Y-%m-%d)T\n' -1

## insertions-deletions
Expand All @@ -42,8 +36,12 @@ net=$(awk -v gd="${gdiff}" 'BEGIN{
# Lean-based reports #
######################

newDeclsTots="$(sed 's=^--\(count_decls\)=\1=' scripts/count_decls.lean | lake env lean --stdin |
sed -z 's=, *=,\n=g; s=[ [#]==g; s=]=,=g; s=\n\n*=\n=g')"
getCountDecls () {
sed 's=^--\(count_decls\)=\1=' scripts/count_decls.lean | lake env lean --stdin |
sed -z 's=, *=,\n=g; s=[ [#]==g; s=]=,=g; s=\n\n*=\n=g'
}

newDeclsTots="$(getCountDecls)"
newDecls="$(echo "${newDeclsTots}" | awk 'BEGIN{ count=0 }
/[^,]$/ { count++; type[count]=$0; acc[count]=0; }
/,$/ { acc[count]++ } END{
Expand All @@ -62,15 +60,18 @@ lake build --quiet
# update the `count_decls` and `mathlib_stats` scripts to the latest version
git checkout -q origin/adomani/periodic_reports_dev_custom_action scripts/count_decls.lean scripts/mathlib_stats.sh

oldDeclsTots="$(sed 's=^--\(count_decls\)=\1=' scripts/count_decls.lean | lake env lean --stdin |
sed -z 's=, *=,\n=g; s=[ [#]==g; s=]=,=g; s=\n\n*=\n=g')"
# the output of `count_decls`
oldDeclsTots="$(getCountDecls)"

# the tally of the output of `count_decls`
oldDecls="$(echo "${oldDeclsTots}" | awk 'BEGIN{ count=0 }
/[^,]$/ { count++; type[count]=$0; acc[count]=0; }
/,$/ { acc[count]++ } END{
for(t=1; t<=count; t++) { printf("%s %s\n", type[t], acc[t]) }
}')"
# Definitions 73152...

# produce the `+X -Y` report for the declarations in each category
plusMinus="$(for typ in $(echo "$newDeclsTots" | grep "[^,]$" | tr '\n' ' ');
do
comm -123 --total <(echo "${newDeclsTots}" |
Expand All @@ -84,18 +85,6 @@ do
($0 ~ typ) { found=1 }' | sort) | awk '{ printf("%s %s\n", $1, $2)}'
done)"

#awk 'BEGIN{ count=0 }
# ((NFR == NR) && (/[^,]$/)) { count++; newType[count]=$0 }
# ((NFR == NR) && (!/[^,]$/)) { newAcc[$0]=count }
##
# ((NFR != NR) && (/[^,]$/)) { for(t in type) { if(type[t]==$0) { count=t } }; oldType[count]=$0 }
# ((NFR != NR) && (!/[^,]$/)) { oldAcc[$0]=count }
##
# END{
#
# }
# ' <(echo "${newDeclsTots}") <(echo "${oldDeclsTots}")

declSummary="$(paste -d' ' <(echo "${newDecls}") <(echo "${oldDecls}") <(echo "${plusMinus}") |
LC_ALL=en_US.UTF-8 awk 'BEGIN{ print "|Type|New|+-|%|\n|:-:|:-:|:-:|:-:|" }{
printf("| %s | %'"'"'d | +%'"'"'d -%'"'"'d | %4.2f%% |\n", $1, $2, $5, $6, ($2-$4)*100/$2)
Expand All @@ -109,6 +98,4 @@ printf -- ' Reference commits: old %s, new %s.\n\n' "${oldCommitURL}" "${current

printf -- '%s, %s total(insertions-deletions)\n\n' "${gdiff}" "${net}"

#printf -- '---\n\n%s\n\n' "${percent}"

printf -- 'Declarations:\n%s\n\nTake also a look at the [`Mathlib` stats page](%s).\n' "${declSummary}" "${statsURL}"

0 comments on commit 5730c66

Please sign in to comment.