pr.enable()
try:
ret = function(*args, **kwargs)
- except:
- caught = sys.exc_info()[0]
+ 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