• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python resource.getpagesize函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _makebundlefile

def _makebundlefile(part):
    """constructs a temporary bundle file

    part.data should be an uncompressed v1 changegroup"""

    fp = None
    fd, bundlefile = tempfile.mkstemp()
    try: # guards bundlefile
        try: # guards fp
            fp = os.fdopen(fd, 'wb')
            magic = 'HG10UN'
            fp.write(magic)
            data = part.read(resource.getpagesize() - len(magic))
            while data:
                fp.write(data)
                data = part.read(resource.getpagesize())
        finally:
            fp.close()
    except:
        try:
            os.unlink(bundlefile)
        except:
            # we would rather see the original exception
            pass
        raise

    return bundlefile
开发者ID:Nephyrin,项目名称:bzexport,代码行数:27,代码来源:__init__.py


示例2: periodicCheck

def periodicCheck(_reactor=reactor):
    # Measure how much garbage we have
    garbage_count = len(gc.garbage)
    MetricCountEvent.log('gc.garbage', garbage_count, absolute=True)
    if garbage_count == 0:
        level = ALARM_OK
    else:
        level = ALARM_WARN
    MetricAlarmEvent.log('gc.garbage', level=level)

    if resource:
        r = resource.getrusage(resource.RUSAGE_SELF)
        attrs = ['ru_utime', 'ru_stime', 'ru_maxrss', 'ru_ixrss', 'ru_idrss',
                'ru_isrss', 'ru_minflt', 'ru_majflt', 'ru_nswap',
                'ru_inblock', 'ru_oublock', 'ru_msgsnd', 'ru_msgrcv',
                'ru_nsignals', 'ru_nvcsw', 'ru_nivcsw']
        for i,a in enumerate(attrs):
            # Linux versions prior to 2.6.32 didn't report this value, but we
            # can calculate it from /proc/<pid>/statm
            v = r[i]
            if a == 'ru_maxrss' and v == 0:
                v = _get_rss() * resource.getpagesize() / 1024
            MetricCountEvent.log('resource.%s' % a, v, absolute=True)
        MetricCountEvent.log('resource.pagesize', resource.getpagesize(), absolute=True)
    # Measure the reactor delay
    then = util.now(_reactor)
    dt = 0.1
    def cb():
        now = util.now(_reactor)
        delay = (now - then) - dt
        MetricTimeEvent.log("reactorDelay", delay)
    _reactor.callLater(dt, cb)
开发者ID:Acidburn0zzz,项目名称:build,代码行数:32,代码来源:metrics.py


示例3: native_map_io_space

 def native_map_io_space(self, base, size, unused_cache_type):
     """Map to memory a specific region."""
     if self.devmem_available() and not self.memory_mapping(base, size):
         if logger().VERBOSE:
             logger().log("[helper] Mapping 0x%x to memory" % (base))
         length = max(size, resource.getpagesize())
         page_aligned_base = base - (base % resource.getpagesize())
         mapping = MemoryMapping(self.dev_mem, length, mmap.MAP_SHARED,
                             mmap.PROT_READ | mmap.PROT_WRITE,
                             offset=page_aligned_base)
         self.mappings.append(mapping)
开发者ID:abazhaniuk,项目名称:chipsec,代码行数:11,代码来源:helper.py


示例4: __init__

    def __init__(self, label=None):
        """
        @param (basestring) label ロギング時に [label] と表示される
        """
        self.start_time = time.time()
        self.latest_time = time.time()
        self.label = label
        self._inner_log = []

        self.start_mem = float(getrusage(RUSAGE_SELF)[6]*getpagesize())
        self.latest_mem = float(getrusage(RUSAGE_SELF)[6]*getpagesize())
开发者ID:subc,项目名称:anchovy,代码行数:11,代码来源:elapsed_time_watch.py


示例5: periodicCheck

def periodicCheck(_reactor=reactor):
    try:
        # Measure how much garbage we have
        garbage_count = len(gc.garbage)
        MetricCountEvent.log("gc.garbage", garbage_count, absolute=True)
        if garbage_count == 0:
            level = ALARM_OK
        else:
            level = ALARM_WARN
        MetricAlarmEvent.log("gc.garbage", level=level)

        if resource:
            r = resource.getrusage(resource.RUSAGE_SELF)
            attrs = [
                "ru_utime",
                "ru_stime",
                "ru_maxrss",
                "ru_ixrss",
                "ru_idrss",
                "ru_isrss",
                "ru_minflt",
                "ru_majflt",
                "ru_nswap",
                "ru_inblock",
                "ru_oublock",
                "ru_msgsnd",
                "ru_msgrcv",
                "ru_nsignals",
                "ru_nvcsw",
                "ru_nivcsw",
            ]
            for i, a in enumerate(attrs):
                # Linux versions prior to 2.6.32 didn't report this value, but we
                # can calculate it from /proc/<pid>/statm
                v = r[i]
                if a == "ru_maxrss" and v == 0:
                    v = _get_rss() * resource.getpagesize() / 1024
                MetricCountEvent.log("resource.%s" % a, v, absolute=True)
            MetricCountEvent.log("resource.pagesize", resource.getpagesize(), absolute=True)
        # Measure the reactor delay
        then = util.now(_reactor)
        dt = 0.1

        def cb():
            now = util.now(_reactor)
            delay = (now - then) - dt
            MetricTimeEvent.log("reactorDelay", delay)

        _reactor.callLater(dt, cb)
    except Exception:
        log.err(None, "while collecting VM metrics")
开发者ID:pepsiman,项目名称:buildbot,代码行数:51,代码来源:metrics.py


示例6: get_mem_usage_virt_and_res

def get_mem_usage_virt_and_res():
    """
    This only works on Linux, and only if the /proc/$PID/statm output is the
    same as that in linux kernel 2.6.  Also `os.getpid()' must work.
    """
    try:
        import resource
    except ImportError:
        raise NotSupportedException
    # sample output from cat /proc/$PID/statm:
    # 14317 3092 832 279 0 2108 0
    a = os.popen("cat /proc/%s/statm" % os.getpid()).read().split()
    if not len(a) > 1:
        raise NotSupportedException
    return (int(a[0]) * resource.getpagesize(), int(a[1]) * resource.getpagesize(),)
开发者ID:ANTH040,项目名称:CouchPotatoServer,代码行数:15,代码来源:memutil.py


示例7: _check_mlock_unevictable

 def _check_mlock_unevictable(self):
     """
     Check nr_mlock and nr_unevictable with guest memory
     """
     if self.realtime_mlock == "on":
         vm_pages = self.vm_mem * 1024 * 1024 / getpagesize()
         nr_mlock = self.mlock_post - self.mlock_pre
         nr_unevictable = self.unevictable_post - self.unevictable_pre
         if nr_mlock < vm_pages:
             self.test.fail("nr_mlock is not fit with VM memory"
                            " when mlock is %s!"
                            " nr_mlock = %d, vm_mem = %d."
                            % (self.realtime_mlock, nr_mlock, self.vm_mem))
         if nr_unevictable < vm_pages:
             self.test.fail("nr_unevictable is not fit with VM memory"
                            " when mlock is %s!"
                            " nr_unevictable = %d, vm_mem = %d."
                            % (self.realtime_mlock, nr_unevictable,
                               self.vm_mem))
     else:
         if self.mlock_post != self.mlock_pre:
             self.test.fail("mlock_post != mlock_pre when mlock is %s!"
                            % self.realtime_mlock)
         if self.unevictable_post != self.unevictable_pre:
             self.test.fail("unevictable_post != unevictable_pre"
                            " when mlock is %s!"
                            % self.realtime_mlock)
开发者ID:bssrikanth,项目名称:tp-qemu,代码行数:27,代码来源:mlock_basic.py


示例8: main

def main():
    """Main Loop."""
    APPNAME = str(__package__ or __doc__)[:99].lower().strip().replace(" ", "")
    if not sys.platform.startswith("win") and sys.stderr.isatty():
        def add_color_emit_ansi(fn):
            """Add methods we need to the class."""
            def new(*args):
                """Method overload."""
                if len(args) == 2:
                    new_args = (args[0], copy(args[1]))
                else:
                    new_args = (args[0], copy(args[1]), args[2:])
                if hasattr(args[0], 'baseFilename'):
                    return fn(*args)
                levelno = new_args[1].levelno
                if levelno >= 50:
                    color = '\x1b[31;5;7m\n '  # blinking red with black
                elif levelno >= 40:
                    color = '\x1b[31m'  # red
                elif levelno >= 30:
                    color = '\x1b[33m'  # yellow
                elif levelno >= 20:
                    color = '\x1b[32m'  # green
                elif levelno >= 10:
                    color = '\x1b[35m'  # pink
                else:
                    color = '\x1b[0m'  # normal
                try:
                    new_args[1].msg = color + str(new_args[1].msg) + ' \x1b[0m'
                except Exception as reason:
                    print(reason)  # Do not use log here.
                return fn(*new_args)
            return new
        # all non-Windows platforms support ANSI Colors so we use them
        log.StreamHandler.emit = add_color_emit_ansi(log.StreamHandler.emit)
    log.basicConfig(level=-1, format="%(levelname)s:%(asctime)s %(message)s")
    log.getLogger().addHandler(log.StreamHandler(sys.stderr))
    log.info(__doc__)
    try:
        os.nice(19)  # smooth cpu priority
        libc = cdll.LoadLibrary('libc.so.6')  # set process name
        buff = create_string_buffer(len(APPNAME) + 1)
        buff.value = bytes(APPNAME.encode("utf-8"))
        libc.prctl(15, byref(buff), 0, 0, 0)
    except Exception as reason:
        log.warning(reason)
    signal.signal(signal.SIGINT, signal.SIG_DFL)  # CTRL+C work to quit app
    app = QApplication(sys.argv)
    app.setApplicationName(APPNAME)
    app.setOrganizationName(APPNAME)
    app.setOrganizationDomain(APPNAME)
    app.instance().setQuitOnLastWindowClosed(False)  # no quit on dialog close
    icon = QIcon(app.style().standardPixmap(QStyle.SP_FileIcon))
    app.setWindowIcon(icon)
    win = MainWindow(icon)
    win.show()
    log.info('Total Maximum RAM Memory used: ~{} MegaBytes.'.format(int(
        resource.getrusage(resource.RUSAGE_SELF).ru_maxrss *
        resource.getpagesize() / 1024 / 1024 if resource else 0)))
    sys.exit(app.exec_())
开发者ID:janusnic,项目名称:unicodemoticon,代码行数:60,代码来源:unicodemoticon.py


示例9: memory_used

def memory_used():
    """Returns the amount of resident memory in use in MBs.

    """

    # FIXME  Need to fill out appropriate methods here for
    # different platforms.

    # For Linux use the proc filesystem. Use 'statm' as easier
    # to parse than 'status' file.
    #
    #   /proc/[number]/statm
    #          Provides information about memory usage, measured in pages.
    #          The columns are:
    #
    #              size       total program size
    #                         (same as VmSize in /proc/[number]/status)
    #              resident   resident set size
    #                         (same as VmRSS in /proc/[number]/status)
    #              share      shared pages (from shared mappings)
    #              text       text (code)
    #              lib        library (unused in Linux 2.6)
    #              data       data + stack
    #              dt         dirty pages (unused in Linux 2.6)

    if sys.platform == 'linux2':
        pid = os.getpid()
        statm = '/proc/%d/statm' % pid
        fp = None

        try:
            fp = open(statm, 'r')
            rss_pages = float(fp.read().split()[1])
            memory_bytes = rss_pages * resource.getpagesize()
            return memory_bytes / (1024*1024)
        except Exception:
            pass
        finally:
            if fp:
                fp.close()

    # Fallback to trying to use getrusage(). The units returned
    # can differ based on platform. Assume 1024 byte blocks as
    # default.

    if 'resource' in sys.modules:
        rusage = resource.getrusage(resource.RUSAGE_SELF)
        if sys.platform == 'darwin':
            # On MacOS X, despite the manual page saying the
            # value is in kilobytes, it is actually in bytes.

            memory_bytes = float(rusage.ru_maxrss)
            return memory_bytes / (1024*1024)
        else:
            memory_kbytes = float(rusage.ru_maxrss)
            return memory_kbytes / 1024

    # Fallback to indicating no memory usage.

    return 0
开发者ID:dmathewwws,项目名称:twitter-sentiment-analysis-python,代码行数:60,代码来源:memory_usage.py


示例10: getProcRss

def getProcRss(procId):
	# http://man7.org/linux/man-pages/man5/proc.5.html
	stats = open("/proc/%i/stat" % procId).read().split()
	mstats = open("/proc/%i/statm" % procId).read().split()
	rss1 = int(stats[23])
	rss2 = int(mstats[1])
	return rss2 * resource.getpagesize()
开发者ID:MichalAugustyn,项目名称:helpers,代码行数:7,代码来源:cgroup-mem-limit-watcher.py


示例11: __init__

    def __init__(self, commands, timeout, interval, output_dir=None, monitor_dir=None):
        self.start_time = time()
        self.end_time = self.start_time + timeout if timeout else 0  # Do not time out if time_limit is 0.
        self._interval = interval

        self._rm = ResourceMonitor(output_dir, commands)
        if monitor_dir:
            self.monitor_file = open(monitor_dir + "/resource_usage.log", "w", (1024 ** 2) * 10)  # Set the file's buffering to 10MB
            # We read the jiffie -> second conversion rate from the os, by dividing the utime
            # and stime values by this conversion rate we will get the actual cpu seconds spend during this second.
            try:
                sc_clk_tck = float(sysconf(sysconf_names['SC_CLK_TCK']))
            except AttributeError:
                sc_clk_tck = 100.0

            try:
                import resource
                pagesize = resource.getpagesize()
            except:
                pagesize = 4 * 1024

            self.monitor_file.write(json.dumps({"sc_clk_tck": sc_clk_tck, 'pagesize': pagesize}) + "\n")
        else:
            self.monitor_file = None
        # Capture SIGTERM to kill all the child processes before dying
        self.stopping = False
        signal(SIGTERM, self._termTrap)
开发者ID:corpaul,项目名称:gumby,代码行数:27,代码来源:process_guard.py


示例12: get_socket_info

    def get_socket_info(self, openr=open):
        """
        get info from /proc/net/sockstat and sockstat6

        Note: The mem value is actually kernel pages, but we return bytes
        allocated based on the systems page size.
        """
        sockstat = {}
        try:
            with openr('/proc/net/sockstat', 'r') as proc_sockstat:
                for entry in proc_sockstat:
                    if entry.startswith("TCP: inuse"):
                        tcpstats = entry.split()
                        sockstat['tcp_in_use'] = int(tcpstats[2])
                        sockstat['orphan'] = int(tcpstats[4])
                        sockstat['time_wait'] = int(tcpstats[6])
                        sockstat['tcp_mem_allocated_bytes'] = \
                            int(tcpstats[10]) * getpagesize()
        except IOError as e:
            if e.errno != errno.ENOENT:
                raise
        try:
            with openr('/proc/net/sockstat6', 'r') as proc_sockstat6:
                for entry in proc_sockstat6:
                    if entry.startswith("TCP6: inuse"):
                        sockstat['tcp6_in_use'] = int(entry.split()[2])
        except IOError as e:
            if e.errno != errno.ENOENT:
                raise
        return sockstat
开发者ID:UshF,项目名称:swift,代码行数:30,代码来源:recon.py


示例13: memoryWriteLoop

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,代码行数:26,代码来源:MemoryUsageLoop.py


示例14: get_page_size

def get_page_size():
    global cache_page_size

    if not cache_page_size:
        cache_page_size = resource.getpagesize()

    return cache_page_size
开发者ID:CENSUS,项目名称:shadow,代码行数:7,代码来源:gdb_engine.py


示例15: __init__

    def __init__(self, config, logger, readq):
        super(Netstat, self).__init__(config, logger, readq)

        self.page_size = resource.getpagesize()
        try:
            self.sockstat = open("/proc/net/sockstat")
            self.netstat = open("/proc/net/netstat")
            self.snmp = open("/proc/net/snmp")
        except IOError:
            self.log_exception('open failed')
            self.cleanup()
            raise
        with utils.lower_privileges(self._logger):
            # 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.
            self.regexp = re.compile("sockets: used \d+\n"
                                     "TCP: inuse (?P<tcp_inuse>\d+) orphan (?P<orphans>\d+)"
                                     " tw (?P<tw_count>\d+) alloc (?P<tcp_sockets>\d+)"
                                     " mem (?P<tcp_pages>\d+)\n"
                                     "UDP: inuse (?P<udp_inuse>\d+)"
                                     # UDP memory accounting was added in v2.6.25-rc1
                                     "(?: mem (?P<udp_pages>\d+))?\n"
                                     # UDP-Lite (RFC 3828) was added in v2.6.20-rc2
                                     "(?:UDPLITE: inuse (?P<udplite_inuse>\d+)\n)?"
                                     "RAW: inuse (?P<raw_inuse>\d+)\n"
                                     "FRAG: inuse (?P<ip_frag_nqueues>\d+)"
                                     " memory (?P<ip_frag_mem>\d+)\n")
开发者ID:wangy1931,项目名称:tcollector,代码行数:30,代码来源:netstat.py


示例16: __init__

    def __init__(self, engine, config_dict):
        super(PiMonitor, self).__init__(engine, config_dict)

        d = config_dict.get('PiMonitor', {})
        self.process = d.get('process', 'weewxd')
        self.max_age = weeutil.weeutil.to_int(d.get('max_age', 2592000))
        self.page_size = resource.getpagesize()
	# get the remote_url from weewx.conf, defaulting to a sane default
	# this does not work
	#self.remote_url = d.get('remote_url', 'http://localhost/test.json')
	self.remote_url = d.get('remote_url', 'http://r/t.json')

        # get the database parameters we need to function
        binding = d.get('data_binding', 'pi_binding')
        self.dbm = self.engine.db_binder.get_manager(data_binding=binding,
                                                     initialize=True)

        # be sure database matches the schema we have
        dbcol = self.dbm.connection.columnsOf(self.dbm.table_name)
        dbm_dict = weewx.manager.get_manager_dict(
            config_dict['DataBindings'], config_dict['Databases'], binding)
        picol = [x[0] for x in dbm_dict['schema']]
        if dbcol != picol:
            raise Exception('pi schema mismatch: %s != %s' % (dbcol, picol))

        self.last_ts = None
        self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record)
开发者ID:vinceskahan,项目名称:vds-weewx-local-skin,代码行数:27,代码来源:pi.py


示例17: execute

def execute(target, directory):
    page_size = resource.getpagesize()
    rows = []

    if directory:
        for (path, dirs, files) in os.walk(target):
            for myfile in files:
                f = os.path.join(path, myfile)
                fd = file(f,'r')
                file_size = os.fstat(fd.fileno())[stat.ST_SIZE]
                if file_size == 0:
                    fd.close()
                    continue
                pages_cached, pages_total = ftools.fincore_ratio(fd.fileno())
                fd.close()
                rows.append([f, file_size, pages_total, pages_cached, (pages_cached * page_size), (float(pages_cached) / float(pages_total)) * 100.0])
    else:
        fd = file(target, 'r')
        file_size = os.fstat(fd.fileno())[stat.ST_SIZE]
        if file_size == 0:
            fd.close()
            return None
        else:
            pages_cached, pages_total = ftools.fincore_ratio(fd.fileno())
            fd.close()
            rows.append([target, file_size, pages_total, pages_cached, (pages_cached * page_size), (float(pages_cached) / float(pages_total)) * 100.0])

    rows = sorted(rows, key=lambda t: t[5], reverse=True)
    return rows
开发者ID:smartcat-labs,项目名称:smartcat-os-metrics,代码行数:29,代码来源:fincore.py


示例18: test_constant_values

    def test_constant_values(self):
        """test that constants are what I expect"""
        self.assertEqual(posix_ipc.O_CREAT, os.O_CREAT)
        self.assertEqual(posix_ipc.O_EXCL, os.O_EXCL)
        self.assertEqual(posix_ipc.O_CREX, posix_ipc.O_CREAT | posix_ipc.O_EXCL)
        self.assertEqual(posix_ipc.O_TRUNC, os.O_TRUNC)

        self.assertEqual(posix_ipc.PAGE_SIZE, resource.getpagesize())

        self.assertIn(posix_ipc.SEMAPHORE_TIMEOUT_SUPPORTED, (True, False))
        self.assertIn(posix_ipc.SEMAPHORE_VALUE_SUPPORTED, (True, False))

        self.assertGreaterEqual(posix_ipc.SEMAPHORE_VALUE_MAX, 1)

        self.assertIn(posix_ipc.MESSAGE_QUEUES_SUPPORTED, (True, False))

        if posix_ipc.MESSAGE_QUEUES_SUPPORTED:
            self.assertGreaterEqual(posix_ipc.QUEUE_MESSAGES_MAX_DEFAULT, 1)
            self.assertGreaterEqual(posix_ipc.QUEUE_MESSAGE_SIZE_MAX_DEFAULT, 1)
            self.assertGreaterEqual(posix_ipc.QUEUE_PRIORITY_MAX, 0)

        if hasattr(posix_ipc, 'USER_SIGNAL_MIN'):
            self.assertGreaterEqual(posix_ipc.USER_SIGNAL_MIN, 1)
        if hasattr(posix_ipc, 'USER_SIGNAL_MAX'):
            self.assertGreaterEqual(posix_ipc.USER_SIGNAL_MAX, 1)

        self.assertTrue(isinstance(posix_ipc.VERSION, str))
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:27,代码来源:test_module.py


示例19: memory_sum

def memory_sum():
    logging.info("Getting memory all")
    dic = {}
    dic["size"] = 0
    dic["resident"] = 0
    dic["share"] = 0
    dic["text"] = 0
    dic["SUM"] = 0
    pids = []
    for pid in os.listdir("/proc"):
        if pid.isdigit():
            pids.append(pid)
    for pid in pids:
        try:
            with open("/proc/{}/statm".format(pid)) as f:
                mem = f.read().split()

                dic["size"] += int(mem[0])
                dic["resident"] += int(mem[1])
                dic["share"] += int(mem[2])
                dic["text"] += int(mem[3])
                dic["SUM"] += int(mem[0]) + int(mem[1]) + int(mem[2]) + \
                    int(mem[3])  # + int(mem[5])
        except FileNotFoundError:
            logging.error("/proc/{}/statm not found".format(pid))
            continue

    pagesize = resource.getpagesize()

    for key in dic:
        dic[key] *= pagesize / 2**20

    return dic
开发者ID:DanielHipp,项目名称:Betriebssysteme,代码行数:33,代码来源:helper.py


示例20: cma_stats

    def cma_stats(self):
        """Get current CMA memory Stats.

        `CMA Memory Available` : Systemwide CMA memory availability.
        
        `CMA Memory Usage` : CMA memory used by current object.
        
        `Buffer Count` : Buffers allocated by current object.

        Parameters
        ----------
        None

        Returns
        -------
        dict
            Dictionary of current stats.

        """
        stats = {}
        free_pages = libxlnk.cma_pages_available()
        stats['CMA Memory Available'] = resource.getpagesize() * free_pages
        memused = 0
        for key in self.bufmap:
            memused += self.bufmap[key]
        stats['CMA Memory Usage'] = memused
        stats['Buffer Count'] = len(self.bufmap)
        return stats
开发者ID:hexanoid,项目名称:PYNQ,代码行数:28,代码来源:xlnk.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python resource.getrlimit函数代码示例发布时间:2022-05-26
下一篇:
Python resource.get_image函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap