https://github.com/chill90/BoloCalc
Tip revision: 319970ac13404ef6a04d041b3db5552081b397e2 authored by Charles Hill on 29 September 2020, 20:55:58 UTC
Fixed bug for power from sky in optical_power.txt
Fixed bug for power from sky in optical_power.txt
Tip revision: 319970a
profile.py
import sys as sy
import cProfile as cp
import io
import pstats as ps
# Profiler decorator
def profiler(func):
def inner(*args, **kwargs):
pr = cp.Profile()
pr.enable()
retval = func(*args, **kwargs)
pr.disable()
s = io.StringIO()
# sortby = 'cumulative'
sortby = 'tottime'
pstat = ps.Stats(pr, stream=s).sort_stats(sortby)
pstat.print_stats()
sy.stdout.write(s.getvalue())
return retval
return inner