https://github.com/chill90/BoloCalc
Raw File
Tip revision: 5b5fe53b155ebb7d1750975b0baa64bc7c3a04fb authored by Charles Hill on 17 September 2020, 07:23:00 UTC
Handling for updated atmosphere files
Tip revision: 5b5fe53
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
back to top