Skip to content

Instantly share code, notes, and snippets.

@steveire
Created Oct 19, 2019
Embed
What would you like to do?
#!/usr/bin/env python
import os
import subprocess
import datetime
lastDate = datetime.datetime.today()
firstDate = lastDate - datetime.timedelta(days=7*52*3)
testDate = firstDate
with open("plot.dat", "w") as f:
reflist = []
while testDate < lastDate:
testDate += datetime.timedelta(days=7)
s = subprocess.Popen("git rev-list -1 --before='{}' origin/master".format(testDate), shell=True, stdout=subprocess.PIPE)
reflist.append(s.stdout.read().strip())
for i, ref in enumerate(reflist):
s = subprocess.Popen("git checkout {}".format(ref), shell=True, stdout=subprocess.PIPE)
s.stdout.read().strip()
s = subprocess.Popen("find -maxdepth 2 -name lib | xargs git grep -e \"\\bauto\\b\" --and --not -e \"\\bauto.* = .*<.*>\" | wc -l", shell=True, stdout=subprocess.PIPE)
assignCount = s.stdout.read().strip()
f.write("{}, {}, {}\n".format(i, assignCount, ref))
with open("plot.gnu", "w") as f:
f.write("""
set title "auto usage over last 3 years"
set label "{firstDate}" at graph 0.00, 1.05
set label "{lastDate}" at graph 0.9, 1.05
unset multiplot
set style data lines
set term png size 1200, 800
set timefmt "%Y-%m-%d"
set output "autousage.png"
stats 'plot.dat' using 1 name 'x' nooutput
set xtics 0,10,x_max
set xlabel "Weeks since 2016-10-22"
set ylabel "Occurances of auto"
plot "plot.dat" using 1:2 t "assign"
set autoscale y
""".format(firstDate=firstDate.strftime("%Y-%m-%d"),
lastDate=lastDate.strftime("%Y-%m-%d")))
s = subprocess.call(["gnuplot", "plot.gnu"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment