Skip to content

Commit

Permalink
improve measure script
Browse files Browse the repository at this point in the history
  • Loading branch information
danprince committed Aug 30, 2023
1 parent 8860218 commit 5689748
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion scripts/measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,32 @@ file=$1
max_size=13312 # (13 * 1024)
size=$(ls -l "$file" | awk '{ print $5 }')
percent=$(echo "$size / $max_size * 100" | bc -l)
printf "%d/%d bytes (%.2f%%)\n" "$size" "$max_size" "$percent"
emoji=$( (( size <= max_size )) && echo "" || echo "")
printf "%s %d/%d bytes (%.2f%%)\n" "$emoji" "$size" "$max_size" "$percent"

if [[ -n "$GITHUB_STEP_SUMMARY" ]]; then
printf "
\`\`\`mermaid
%%%%{
init: {
'theme': 'base',
'themeVariables': {
'pie1': '#b12a34',
'pie2': '#fff',
'pieOpacity': 1,
'fontFamily': 'monospace',
'pieStrokeWidth': '4px',
'pieSectionTextSize': '40px',
'pieTitleTextSize': '30px',
'pieLegendTextSize': '25px'
}
}
}%%%%
pie showData
title Budget (%.2f%%) %s
\"Used (bytes)\": %d
\"Free (bytes)\": %d
\`\`\`
" "$percent" "$emoji" "$size" "$((max_size - size))" > "$GITHUB_STEP_SUMMARY"
fi

0 comments on commit 5689748

Please sign in to comment.