def invoke(self, args, from_tty): ms = glibc_arenas.get_ms() chunks_by_size = {} num_chunks = 0 total_size = 0 try: for chunk in ms.iter_chunks(): if not chunk.is_inuse(): continue size = int(chunk.chunksize()) num_chunks += 1 total_size += size if size in chunks_by_size: chunks_by_size[size] += 1 else: chunks_by_size[size] = 1 except KeyboardInterrupt: pass # FIXME t = Table(['Chunk size', 'Num chunks', 'Allocated size']) for size in sorted(chunks_by_size.keys(), lambda s1, s2: chunks_by_size[s2] * s2 - chunks_by_size[s1] * s1): t.add_row([fmt_size(size), chunks_by_size[size], fmt_size(chunks_by_size[size] * size)]) t.add_row(['TOTALS', num_chunks, fmt_size(total_size)]) t.write(sys.stdout) print()
def stats(self): size_change = self.new.total_size() - self.old.total_size() count_change = self.new._num_usage - self.old._num_usage return "%s%s bytes, %s%s blocks" % (sign(size_change), fmt_size(size_change), sign(count_change), fmt_size(count_change))
def invoke(self, args, from_tty): total_by_category = {} count_by_category = {} total_size = 0 total_count = 0 try: usage_list = list(lazily_get_usage_list()) for u in usage_list: u.ensure_category() total_size += u.size if u.category in total_by_category: total_by_category[u.category] += u.size else: total_by_category[u.category] = u.size total_count += 1 if u.category in count_by_category: count_by_category[u.category] += 1 else: count_by_category[u.category] = 1 except KeyboardInterrupt: pass # FIXME t = Table(['Domain', 'Kind', 'Detail', 'Count', 'Allocated size']) for category in sorted(total_by_category.keys(), key=total_by_category.get, reverse=True): detail = category.detail if not detail: detail = '' t.add_row([ category.domain, category.kind, detail, fmt_size(count_by_category[category]), fmt_size(total_by_category[category]), ]) t.add_row( ['', '', 'TOTAL', fmt_size(total_count), fmt_size(total_size)]) t.write(sys.stdout) print()
def invoke(self, args, from_tty): total_by_category = {} count_by_category = {} total_size = 0 total_count = 0 try: usage_list = list(lazily_get_usage_list()) for u in usage_list: u.ensure_category() total_size += u.size if u.category in total_by_category: total_by_category[u.category] += u.size else: total_by_category[u.category] = u.size total_count += 1 if u.category in count_by_category: count_by_category[u.category] += 1 else: count_by_category[u.category] = 1 except KeyboardInterrupt: pass # FIXME t = Table(['Domain', 'Kind', 'Detail', 'Count', 'Allocated size']) for category in sorted(total_by_category.keys(), lambda s1, s2: cmp(total_by_category[s2], total_by_category[s1]) ): detail = category.detail if not detail: detail = '' t.add_row([category.domain, category.kind, detail, fmt_size(count_by_category[category]), fmt_size(total_by_category[category]), ]) t.add_row(['', '', 'TOTAL', fmt_size(total_count), fmt_size(total_size)]) t.write(sys.stdout) print
def stats(self): size_change = self.new.total_size() - self.old.total_size() count_change = self.new._num_usage - self.old._num_usage return "%s%s bytes, %s%s blocks" % ( sign(size_change), fmt_size(size_change), sign(count_change), fmt_size(count_change))
def summary(self): return '%s allocated, in %i blocks' % (fmt_size( self.total_size()), self._num_usage)
def summary(self): return '%s allocated, in %i blocks' % (fmt_size(self.total_size()), self._num_usage)