Skip to content

Instantly share code, notes, and snippets.

@kahrl
Created September 8, 2014 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kahrl/9135ee4a92693dc2c051 to your computer and use it in GitHub Desktop.
Save kahrl/9135ee4a92693dc2c051 to your computer and use it in GitHub Desktop.
#
# Relevant history:
#
# commit 1995b59320fe0fdced55c4605635f38cc42768f1 (2011-04-23)
# Moved lots of code from main.cpp:main() to game.cpp:the_game()
#
# commit 4e249fb3fbf75f0359758760d88e22aa5b14533c (2010-09-27)
# First git commit. Minetest existed before then but not in git.
#
#git log --before=2013-01-01 --pretty=format:%H -1
plotfile=the_game_graph.gnuplot
pngfile=the_game_graph.png
echo > $plotfile
echo "set terminal png size 900, 300" >> $plotfile
echo "set output \"$pngfile\"" >> $plotfile
echo "set yrange [0:3000]" >> $plotfile
echo "set xdata time" >> $plotfile
echo "set timefmt \"%Y-%m-%d\"" >> $plotfile
echo "set format x \"%Y-%m\"" >> $plotfile
echo "plot [:][:] '-' using 1:2 title \"Length of main()\" with lines, '-' using 1:2 title \"Length of the_game()\" with lines" >> $plotfile
###########
function collect_data() {
lastdate=
while [ "$currentdate" != "$enddate" ]; do
currentdate=$(date +%Y-%m-%d -d "$currentdate +1 day")
if [ "${currentdate:0:4}" != "${lastdate:0:4}" ]; then
echo "Processing year: ${currentdate:0:4}"
fi
lastdate=$currentdate
commithash=$(git log master --before=$currentdate --pretty=format:%H -1)
millikloc=$(git show $commithash:$culpritfile | awk "BEGIN { state = 0; n = 0; } /^$culpritreturntype $culpritfunc\(/ { state=1 } { if ( state == 1 ) { n = n+1 } } /^}/ { if ( state == 1 ) { state = 2 } } END { print n }")
echo "$currentdate $millikloc" >> $plotfile
done
echo "e" >> $plotfile
}
###########
echo 'Processing data for main()'
culpritfile=../src/main.cpp
culpritfunc=main
culpritreturntype=int
currentdate=2010-09-27
enddate=$(date +%Y-%m-%d)
collect_data
###########
echo 'Processing data for the_game()'
culpritfile=../src/game.cpp
culpritfunc=the_game
culpritreturntype=void
currentdate=2011-04-24
enddate=$(date +%Y-%m-%d)
collect_data
###########
if gnuplot $plotfile; then
echo "Graph has been written to $pngfile."
else
echo "Error: gnuplot failed."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment