Mercurial > hg
view tests/test-install.t @ 27784:432242f41d9f
obsolete: make _computeobsoleteset much faster
This patch makes _computeobsoleteset much faster by looping
over the draft and secrets as opposed to looping over the
successors.
This works because "number of draft and secret" is typically
way smaller(<100) than the number of successor in the repo (~90k in
my checkout of core mercurial as of today). And also because
it is very fast to compute "not public()".
I timed the code with the following setup:
"""
from mercurial import hg, ui, obsolete
ui = ui.ui()
repo = hg.repository(ui, "~/hg")
l = repo.obsstore.successors # This caches the result
"""
With about 90k successors.
k=obsolete._computeobsoleteset(repo) before this patch:
10 loops, best of 3: 33.9 ms per loop
k=obsolete._computeobsoleteset(repo) after this patch:
10000 loops, best of 3: 83.3 µs per loop
author | Laurent Charignon <lc2817@columbia.edu> |
---|---|
date | Wed, 13 Jan 2016 21:52:26 -0800 |
parents | e9857fbfd072 |
children | 855d9b2eea67 |
line wrap: on
line source
hg debuginstall $ hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) checking Python version (2.*) (glob) checking Python lib (*lib*)... (glob) checking installed modules (*mercurial)... (glob) checking templates (*mercurial?templates)... (glob) checking commit editor... checking username... no problems detected hg debuginstall with no username $ HGUSER= hg debuginstall checking encoding (ascii)... checking Python executable (*) (glob) checking Python version (2.*) (glob) checking Python lib (*lib*)... (glob) checking installed modules (*mercurial)... (glob) checking templates (*mercurial?templates)... (glob) checking commit editor... checking username... no username supplied (specify a username in your configuration file) 1 problems detected, please check your install! [1] path variables are expanded (~ is the same as $TESTTMP) $ mkdir tools $ touch tools/testeditor.exe #if execbit $ chmod 755 tools/testeditor.exe #endif $ hg debuginstall --config ui.editor=~/tools/testeditor.exe checking encoding (ascii)... checking Python executable (*) (glob) checking Python version (*) (glob) checking Python lib (*lib*)... (glob) checking installed modules (*mercurial)... (glob) checking templates (*mercurial?templates)... (glob) checking commit editor... checking username... no problems detected #if test-repo $ cat >> wixxml.py << EOF > import os, subprocess, sys > import xml.etree.ElementTree as ET > > # MSYS mangles the path if it expands $TESTDIR > testdir = os.environ['TESTDIR'] > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'} > > def directory(node, relpath): > '''generator of files in the xml node, rooted at relpath''' > dirs = node.findall('./{%(wix)s}Directory' % ns) > > for d in dirs: > for subfile in directory(d, relpath + d.attrib['Name'] + '/'): > yield subfile > > files = node.findall('./{%(wix)s}Component/{%(wix)s}File' % ns) > > for f in files: > yield relpath + f.attrib['Name'] > > def hgdirectory(relpath): > '''generator of tracked files, rooted at relpath''' > hgdir = "%s/../mercurial" % (testdir) > args = ['hg', '--cwd', hgdir, 'files', relpath] > proc = subprocess.Popen(args, stdout=subprocess.PIPE, > stderr=subprocess.PIPE) > output = proc.communicate()[0] > > slash = '/' > for line in output.splitlines(): > if os.name == 'nt': > yield line.replace(os.sep, slash) > else: > yield line > > tracked = [f for f in hgdirectory(sys.argv[1])] > > xml = ET.parse("%s/../contrib/wix/%s.wxs" % (testdir, sys.argv[1])) > root = xml.getroot() > dir = root.find('.//{%(wix)s}DirectoryRef' % ns) > > installed = [f for f in directory(dir, '')] > > print('Not installed:') > for f in sorted(set(tracked) - set(installed)): > print(' %s' % f) > > print('Not tracked:') > for f in sorted(set(installed) - set(tracked)): > print(' %s' % f) > EOF $ python wixxml.py help Not installed: help/common.txt help/hg.1.txt help/hgignore.5.txt help/hgrc.5.txt Not tracked: $ python wixxml.py templates Not installed: Not tracked: #endif