monitoring.py 文件源码

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

项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码
def memory_usage():

    # If we are on linux
    if platform == "linux" or platform == "linux2":

        kilobytes = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss # peak memory usage (bytes on OS X, kilobytes on Linux)
        gigabytes = kilobytes * 1e-6

        return gigabytes

    # If we are on Mac OS X
    elif platform == "darwin":

        kilobytes = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss # peak memory usage (bytes on OS X, kilobytes on Linux)
        gigabytes = kilobytes * 1e-9

        return gigabytes

    # We don't support Windows
    elif platform == "win32": raise EnvironmentError("The Windows operating system is not supported")

    # Unrecognized platform
    else: raise EnvironmentError("Unrecognized platform")

# -----------------------------------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号