A port of Andy Wingo's statprof.py to newer python by Alex Fraser