omf.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:FogLAMP 作者: foglamp 项目源码 文件源码
def _performance_log(func):
    """ Logs information for performance measurement """
    def wrapper(*arg):
        """ wrapper """
        start = datetime.datetime.now()
        # Code execution
        res = func(*arg)
        if _log_performance:
            usage = resource.getrusage(resource.RUSAGE_SELF)
            memory_process = (usage[2])/1000
            delta = datetime.datetime.now() - start
            delta_milliseconds = int(delta.total_seconds() * 1000)
            _logger.info("PERFORMANCE - {0} - milliseconds |{1:>8,}| - memory MB |{2:>8,}|"
                         .format(func.__name__,
                                 delta_milliseconds,
                                 memory_process))
        return res
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号