Mercurial > hg
view contrib/memory.py @ 41245:2a8782cc2e16
discovery: using the new basesheads()
Our ultimate goal is to switch eventually to a Rust implementation, but
this move actually seems to increase the performance in a pure Python
build.
What follows is a quick measurement done on PyPy on repos prepared with
`contrib/discovery-helper.sh 50 100`.
Before:
! wall 0.894384 comb 0.890000 user 0.890000 sys 0.000000 (best of 11)
! wall 0.971199 comb 0.970000 user 0.950000 sys 0.020000 (max of 11)
! wall 0.927993 comb 0.925455 user 0.919091 sys 0.006364 (avg of 11)
! wall 0.921619 comb 0.920000 user 0.910000 sys 0.010000 (median of 11)
After:
! wall 0.614278 comb 0.610000 user 0.610000 sys 0.000000 (best of 14)
! wall 0.789459 comb 0.790000 user 0.770000 sys 0.020000 (max of 14)
! wall 0.722765 comb 0.720000 user 0.715714 sys 0.004286 (avg of 14)
! wall 0.734448 comb 0.720000 user 0.720000 sys 0.000000 (median of 14)
Differential Revision: https://phab.mercurial-scm.org/D5583
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Mon, 14 Jan 2019 18:52:01 +0100 |
parents | de5c9d0e02ea |
children | 2372284d9457 |
line wrap: on
line source
# memory.py - track memory usage # # Copyright 2009 Matt Mackall <mpm@selenic.com> and others # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. '''helper extension to measure memory usage Reads current and peak memory usage from ``/proc/self/status`` and prints it to ``stderr`` on exit. ''' from __future__ import absolute_import def memusage(ui): """Report memory usage of the current process.""" result = {'peak': 0, 'rss': 0} with open('/proc/self/status', 'r') as status: # This will only work on systems with a /proc file system # (like Linux). for line in status: parts = line.split() key = parts[0][2:-1].lower() if key in result: result[key] = int(parts[1]) ui.write_err(", ".join(["%s: %.1f MiB" % (k, v / 1024.0) for k, v in result.iteritems()]) + "\n") def extsetup(ui): ui.atexit(memusage, ui)