From 5730c668eadf10abf15e3cfb802c16e22a127336 Mon Sep 17 00:00:00 2001 From: adomani Date: Sat, 18 May 2024 20:23:38 +0200 Subject: [PATCH] remove percentage, small cleanup --- scripts/mathlib_stats.sh | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/scripts/mathlib_stats.sh b/scripts/mathlib_stats.sh index ef5343782e77b..0858eef412700 100755 --- a/scripts/mathlib_stats.sh +++ b/scripts/mathlib_stats.sh @@ -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 @@ -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{ @@ -62,8 +60,10 @@ 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{ @@ -71,6 +71,7 @@ oldDecls="$(echo "${oldDeclsTots}" | awk 'BEGIN{ count=0 } }')" # 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}" | @@ -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) @@ -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}"