pr.enable()
try:
ret = function(*args, **kwargs)
- except e:
+ except Exception as e:
caught = e
pr.disable()
ps = pstats.Stats(pr, stream=outfile)
- ps.print_stats()
+ ps.sort_stats('time').print_stats()
if caught:
- raise caught
+ raise
return ret
return profiled_function