当前位置: 首页>>代码示例>>Python>>正文


Python resource.getpagesize方法代码示例

本文整理汇总了Python中resource.getpagesize方法的典型用法代码示例。如果您正苦于以下问题:Python resource.getpagesize方法的具体用法?Python resource.getpagesize怎么用?Python resource.getpagesize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在resource的用法示例。


在下文中一共展示了resource.getpagesize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_free_pages

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def check_free_pages(page_list, cell_id, free_page, logger):
    """ check page size
    """
    for ps in page_list:
        # if pagesize is equal to system pagesize, since it is hard to
        # calculate, so we just pass it
        if resource.getpagesize() / 1024 == ps:
            logger.info("skip to check default %sKB-page" % ps)
            continue

        sysfs_path = HUGEPAGE_PATH % (cell_id, ps)
        if not os.access(sysfs_path, os.R_OK):
            logger.error("could not find %s" % sysfs_path)
            return False
        f = open(sysfs_path)
        fp = int(f.read())
        f.close()
        if not fp == free_page[0][ps]:
            logger.error("Free %sKB page checking failed" % ps)
            return False
        logger.info("Free %sKB page: %s" % (ps, fp))

    return True 
开发者ID:libvirt,项目名称:libvirt-test-API,代码行数:25,代码来源:free_pages.py

示例2: nlmsg_alloc

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def nlmsg_alloc(len_=default_msg_size):
    """Allocate a new Netlink message with maximum payload size specified.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L299

    Allocates a new Netlink message without any further payload. The maximum payload size defaults to
    resource.getpagesize() or as otherwise specified with nlmsg_set_default_size().

    Returns:
    Newly allocated Netlink message (nl_msg class instance).
    """
    len_ = max(libnl.linux_private.netlink.nlmsghdr.SIZEOF, len_)
    nm = nl_msg()
    nm.nm_refcnt = 1
    nm.nm_nlh = libnl.linux_private.netlink.nlmsghdr(bytearray(b'\0') * len_)
    nm.nm_protocol = -1
    nm.nm_size = len_
    nm.nm_nlh.nlmsg_len = nlmsg_total_size(0)
    _LOGGER.debug('msg 0x%x: Allocated new message, maxlen=%d', id(nm), len_)
    return nm 
开发者ID:Robpol86,项目名称:libnl,代码行数:22,代码来源:msg.py

示例3: main

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def main():
    """Main loop"""
    sys.stdin.close()

    interval = 15
    page_size = resource.getpagesize()

    try:
        sockstat = open("/proc/net/sockstat")
        netstat = open("/proc/net/netstat")
        snmp = open("/proc/net/snmp")
    except IOError, e:
        print >>sys.stderr, "open failed: %s" % e
        return 13  # Ask tcollector to not re-start us.
    #utils.drop_privileges()

    # Note: up until v2.6.37-rc2 most of the values were 32 bits.
    # The first value is pretty useless since it accounts for some
    # socket types but not others.  So we don't report it because it's
    # more confusing than anything else and it's not well documented
    # what type of sockets are or aren't included in this count. 
开发者ID:soarpenguin,项目名称:python-scripts,代码行数:23,代码来源:netstat.py

示例4: test_PAGESIZE

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def test_PAGESIZE(self):
        # pagesize is used internally to perform different calculations
        # and it's determined by using SC_PAGE_SIZE; make sure
        # getpagesize() returns the same value.
        import resource
        self.assertEqual(os.sysconf("SC_PAGE_SIZE"), resource.getpagesize()) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:test_system.py

示例5: memoryWriteLoop

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def memoryWriteLoop(logfileLocation, interval):
    try:
        if isinstance(logfileLocation, file):
            outputFile = logfileLocation
        else:
            outputFile = open(logfileLocation, "w", 0)

        def pad(s, finalLength):
            return s + " " * (finalLength - len(s))

        def formatCols(columns):
            return "".join([pad(columns[0],30)] + [pad(c, 15) for c in columns[1:]])

        columns = ["timestamp", "total size MB", "RSS MB", "shared MB", "code MB", "stack MB", "library MB", "dirty MB"]

        print >> outputFile, formatCols(columns)
        while True:
            with open("/proc/%s/statm" % os.getpid(), "r") as f:
                data = ["%.2f" % (int(x) * resource.getpagesize() / 1024 / 1024.0) for x in f.readline().split(" ")]

            print >> outputFile, formatCols([time.strftime("%Y-%m-%dT%H:%M:%S")] + data)

            time.sleep(interval)
    except:
        import traceback
        traceback.format_exc() 
开发者ID:ufora,项目名称:ufora,代码行数:28,代码来源:MemoryUsageLoop.py

示例6: _get_mem_usage

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def _get_mem_usage(self):
        from resource import getpagesize, getrusage, RUSAGE_SELF
        mem = getrusage(RUSAGE_SELF).ru_maxrss
        return mem * getpagesize() / 1024 / 1024 
开发者ID:holzschu,项目名称:python3_ios,代码行数:6,代码来源:check_imaging_leaks.py

示例7: memusage

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def memusage( point = "") :
    usage = resource.getrusage( resource.RUSAGE_SELF) 
    return '''%s: usertime = %s systime = %s mem = %s mb
           '''%( point, usage[ 0 ], usage[ 1 ], 
                ( usage[ 2 ]*resource.getpagesize( ) ) /1000000.0 ) 
开发者ID:edwin-de-jong,项目名称:incremental-sequence-learning,代码行数:7,代码来源:train.py

示例8: map_init

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def map_init(vars, name, z='badmap_size'):
	if not vars.badmap_size:
		pagesize = getpagesize()
		line_count = vars.lines[vars.sliceno]
		vars.badmap_size = (line_count // 8 // pagesize + 1) * pagesize
		vars.slicemap_size = (line_count * 2 // pagesize + 1) * pagesize
	fh = open(name, 'w+b')
	vars.map_fhs.append(fh)
	fh.truncate(vars[z])
	return fh.fileno() 
开发者ID:eBay,项目名称:accelerator,代码行数:12,代码来源:a_dataset_type.py

示例9: Using

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def Using(point, verb=False):
    usage = resource.getrusage(resource.RUSAGE_SELF)
    if verb: print '%s: usertime=%s systime=%s mem=%s mb' % (point,usage[0],usage[1],
                (usage[2]*resource.getpagesize())/1000000.0 )
    return (usage[2]*resource.getpagesize())/1000000.0 
开发者ID:mzechmeister,项目名称:serval,代码行数:7,代码来源:serval.py

示例10: __init__

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def __init__(self, registry, sys_stats_file=SYS_STATS, process_stats_file=PROC_STATS, memory_stats_file=MEM_STATS):
        self.page_size = resource.getpagesize()
        self.previous = {}
        self._read_data_lock = threading.Lock()
        self.sys_stats_file = sys_stats_file
        self.process_stats_file = process_stats_file
        self.memory_stats_file = memory_stats_file
        self._sys_clock_ticks = os.sysconf("SC_CLK_TCK")
        with self._read_data_lock:
            self.previous.update(self.read_process_stats())
            self.previous.update(self.read_system_stats())
        super(CPUMetricSet, self).__init__(registry) 
开发者ID:elastic,项目名称:apm-agent-python,代码行数:14,代码来源:cpu_linux.py

示例11: memoryUsage

# 需要导入模块: import resource [as 别名]
# 或者: from resource import getpagesize [as 别名]
def memoryUsage():
    statm_labels = [ 'size', 'resident', 'shared', 'text', 'lib', 'data', 'dirty pages' ]
    values = [ int( x ) * resource.getpagesize()
               for x in open( '/proc/{}/statm'.format( os.getpid() ), 'rt' ).read().split( ' ' ) ]
    return dict( zip( statm_labels, values ) ) 
开发者ID:mxmlnkn,项目名称:ratarmount,代码行数:7,代码来源:benchmarkTarfile.py


注:本文中的resource.getpagesize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。