tools/dump_process_memory/analyze_dumps.py
def PrintStats(dumps, verbose):
  """Logs statistics about a process mappings dump.

  Args:
    dumps: ([str]) List of dumps.
    verbose: (bool) Verbose output.
  """
  dump_stats = [_GetStatsFromFileDump(filename) for filename in dumps]
  total = _AggregateStats(dump_stats)
  duplicated_pages = sum(x - 1 for x in total.content_to_count.values())
  count_and_hashes = sorted(((v, k) for k, v in total.content_to_count.items()),
                            reverse=True)
  max_common_pages = count_and_hashes[0][0] - 1
  total_size_non_zero_pages = (total.pages - total.zero_pages) * PAGE_SIZE

  print('Total pages = %d (%s)' % (total.pages,
                                   _PrettyPrintSize(total.pages * PAGE_SIZE)))
  print('Total zero pages = %d (%.02f%%)' %
        (total.zero_pages, (100. * total.zero_pages) / total.pages))
  print('Total present zero pages = %d (%s)' %
        (total.present_zero_pages,
         _PrettyPrintSize(total.present_zero_pages * PAGE_SIZE)))
  print(
      'Total size of non-zero pages = %d (%s)' %
      (total_size_non_zero_pages, _PrettyPrintSize(total_size_non_zero_pages)))
  print('Total compressed size = %d (%.02f%%)' %
        (total.compressed_size,
         (100. * total.compressed_size) / total_size_non_zero_pages))
  print('Duplicated non-zero pages = %d' % duplicated_pages)
  print('Max non-zero pages with the same content = %d' % max_common_pages)
  print(
      'Swapped pages = %d (%s)' %
      (total.swapped_pages, _PrettyPrintSize(total.swapped_pages * PAGE_SIZE)))
  print('Non-present pages = %d (%s)' %
        (total.not_present_pages,
         _PrettyPrintSize(total.not_present_pages * PAGE_SIZE)))
  print('Freed: ')
  for k in total.freed:
    print('  %s = %d (%s)' % (k, total.freed[k], _PrettyPrintSize(
        total.freed[k])))

  if verbose:
    print('Top Duplicated Pages:')
    for i in range(10):
      count, page_hash = count_and_hashes[i]
      print('%d common pages' % count)
      page = _FindPageFromHash(dump_stats, page_hash)
      _PrintPage(page)
      print()
Logs statistics about a process mappings dump.

  Args:
    dumps: ([str]) List of dumps.
    verbose: (bool) Verbose output.
  
Logs statistics about a process mappings dump.
Logs statistics about a process mappings dump .
def PrintStats(dumps, verbose):
  dump_stats = [_GetStatsFromFileDump(filename) for filename in dumps]
  total = _AggregateStats(dump_stats)
  duplicated_pages = sum(x - 1 for x in total.content_to_count.values())
  count_and_hashes = sorted(((v, k) for k, v in total.content_to_count.items()),
                            reverse=True)
  max_common_pages = count_and_hashes[0][0] - 1
  total_size_non_zero_pages = (total.pages - total.zero_pages) * PAGE_SIZE
  print('Total pages = %d (%s)' % (total.pages,
                                   _PrettyPrintSize(total.pages * PAGE_SIZE)))
  print('Total zero pages = %d (%.02f%%)' %
        (total.zero_pages, (100. * total.zero_pages) / total.pages))
  print('Total present zero pages = %d (%s)' %
        (total.present_zero_pages,
         _PrettyPrintSize(total.present_zero_pages * PAGE_SIZE)))
  print(
      'Total size of non-zero pages = %d (%s)' %
      (total_size_non_zero_pages, _PrettyPrintSize(total_size_non_zero_pages)))
  print('Total compressed size = %d (%.02f%%)' %
        (total.compressed_size,
         (100. * total.compressed_size) / total_size_non_zero_pages))
  print('Duplicated non-zero pages = %d' % duplicated_pages)
  print('Max non-zero pages with the same content = %d' % max_common_pages)
  print(
      'Swapped pages = %d (%s)' %
      (total.swapped_pages, _PrettyPrintSize(total.swapped_pages * PAGE_SIZE)))
  print('Non-present pages = %d (%s)' %
        (total.not_present_pages,
         _PrettyPrintSize(total.not_present_pages * PAGE_SIZE)))
  print('Freed: ')
  for k in total.freed:
    print('  %s = %d (%s)' % (k, total.freed[k], _PrettyPrintSize(
        total.freed[k])))
  if verbose:
    print('Top Duplicated Pages:')
    for i in range(10):
      count, page_hash = count_and_hashes[i]
      print('%d common pages' % count)
      page = _FindPageFromHash(dump_stats, page_hash)
      _PrintPage(page)
      print()
def PrintStats ( dumps , verbose ) : dump_stats = [ _GetStatsFromFileDump ( filename ) for filename in dumps ] total = _AggregateStats ( dump_stats ) duplicated_pages = sum ( x - 1 for x in total . content_to_count . values ( ) ) count_and_hashes = sorted ( ( ( v , k ) for k , v in total . content_to_count . items ( ) ) , reverse = True ) max_common_pages = count_and_hashes [ 0 ] [ 0 ] - 1 total_size_non_zero_pages = ( total . pages - total . zero_pages ) * PAGE_SIZE print ( 'Total pages = %d (%s)' % ( total . pages , _PrettyPrintSize ( total . pages * PAGE_SIZE ) ) ) print ( 'Total zero pages = %d (%.02f%%)' % ( total . zero_pages , ( 100. * total . zero_pages ) / total . pages ) ) print ( 'Total present zero pages = %d (%s)' % ( total . present_zero_pages , _PrettyPrintSize ( total . present_zero_pages * PAGE_SIZE ) ) ) print ( 'Total size of non-zero pages = %d (%s)' % ( total_size_non_zero_pages , _PrettyPrintSize ( total_size_non_zero_pages ) ) ) print ( 'Total compressed size = %d (%.02f%%)' % ( total . compressed_size , ( 100. * total . compressed_size ) / total_size_non_zero_pages ) ) print ( 'Duplicated non-zero pages = %d' % duplicated_pages ) print ( 'Max non-zero pages with the same content = %d' % max_common_pages ) print ( 'Swapped pages = %d (%s)' % ( total . swapped_pages , _PrettyPrintSize ( total . swapped_pages * PAGE_SIZE ) ) ) print ( 'Non-present pages = %d (%s)' % ( total . not_present_pages , _PrettyPrintSize ( total . not_present_pages * PAGE_SIZE ) ) ) print ( 'Freed: ' ) for k in total . freed : print ( '  %s = %d (%s)' % ( k , total . freed [ k ] , _PrettyPrintSize ( total . freed [ k ] ) ) ) if verbose : print ( 'Top Duplicated Pages:' ) for i in range ( 10 ) : count , page_hash = count_and_hashes [ i ] print ( '%d common pages' % count ) page = _FindPageFromHash ( dump_stats , page_hash ) _PrintPage ( page ) print ( )
Logs statistics about a process mappings dump.
Logs statistics about a process mappings dump .
"""Logs statistics about a process mappings dump.

  Args:
    dumps: ([str]) List of dumps.
    verbose: (bool) Verbose output.
  """
dumps
([str]) List of dumps.
( [ str ] ) List of dumps .
verbose
(bool) Verbose output.
( bool ) Verbose output .