예제 #1
0
            def vmem():
                from os import sysconf
                PAGE_SIZE = sysconf ('SC_PAGE_SIZE') # in bytes

                from string import split as ssplit
                m = 0
                with open('/proc/self/statm') as f:
                    m = int(ssplit (f.readlines()[0])[0])
                return m * PAGE_SIZE # in bytes
예제 #2
0
            def vmem():
                from os import sysconf
                PAGE_SIZE = sysconf ('SC_PAGE_SIZE') # in bytes

                from string import split as ssplit
                m = 0
                from sys import platform
                with open('/proc/self/statm') as f:
                    m = int(ssplit (f.readlines()[0])[0])
                return m * PAGE_SIZE # in bytes
예제 #3
0
def pymon():
    """returns (cpu[ms], vmem[kb], rss[kb])
    """
    from resource import getrusage, RUSAGE_SELF
    from string import split as ssplit
    cpu = getrusage(RUSAGE_SELF)
    mem = open('/proc/self/statm', 'r')
    cpu = (cpu.ru_utime + cpu.ru_stime) * 1e3  # in milliseconds
    mem = ssplit(mem.readlines()[0])
    vmem = int(mem[0]) * _pagesz
    rss = int(mem[1]) * _pagesz
    return cpu, vmem, rss
예제 #4
0
 def pymon():
     from os import getpid, sysconf
     from sys import platform
     from resource import getrusage, RUSAGE_SELF
     from string import split as ssplit
     cpu = getrusage(RUSAGE_SELF)
     cpu = (cpu.ru_utime + cpu.ru_stime) * 1e3  # in milliseconds
     pageSize = sysconf('SC_PAGE_SIZE') / Units.MB
     mem = open('/proc/%d/statm' % getpid(), 'r')
     mem = ssplit(mem.readlines()[0])
     vmem = int(mem[0]) * pageSize
     rss = int(mem[1]) * pageSize
     return cpu, vmem, rss