comparison contrib/perf.py @ 40768:f723014677a5

perf: add a `perfbranchmapupdate` command This command benchmark the time necessary to update the branchmap between two sets of revisions. This changeset introduce a first version, doing nothing fancy regarding cache or other internal details.
author Boris Feld <boris.feld@octobus.net>
date Wed, 21 Nov 2018 12:02:25 +0000
parents 45a0047c0ebc
children 95f35c873463
comparison
equal deleted inserted replaced
40767:33d30fb1e4ae 40768:f723014677a5
2280 finally: 2280 finally:
2281 branchcacheread.restore() 2281 branchcacheread.restore()
2282 branchcachewrite.restore() 2282 branchcachewrite.restore()
2283 fm.end() 2283 fm.end()
2284 2284
2285 @command(b'perfbranchmapupdate', [
2286 (b'', b'base', [], b'subset of revision to start from'),
2287 (b'', b'target', [], b'subset of revision to end with'),
2288 ] + formatteropts)
2289 def perfbranchmapupdate(ui, repo, base=(), target=(), **opts):
2290 """benchmark branchmap update from for <base> revs to <target> revs
2291
2292 Examples:
2293
2294 # update for the one last revision
2295 $ hg perfbranchmapupdate --base 'not tip' --target 'tip'
2296
2297 $ update for change coming with a new branch
2298 $ hg perfbranchmapupdate --base 'stable' --target 'default'
2299 """
2300 from mercurial import branchmap
2301 opts = _byteskwargs(opts)
2302 timer, fm = gettimer(ui, opts)
2303 x = [None] # used to pass data between closure
2304
2305 # we use a `list` here to avoid possible side effect from smartset
2306 baserevs = list(scmutil.revrange(repo, base))
2307 targetrevs = list(scmutil.revrange(repo, target))
2308 if not baserevs:
2309 raise error.Abort(b'no revisions selected for --base')
2310 if not targetrevs:
2311 raise error.Abort(b'no revisions selected for --target')
2312
2313 # make sure the target branchmap also contains the one in the base
2314 targetrevs = list(set(baserevs) | set(targetrevs))
2315 targetrevs.sort()
2316
2317 cl = repo.changelog
2318 allbaserevs = list(cl.ancestors(baserevs, inclusive=True))
2319 allbaserevs.sort()
2320 alltargetrevs = frozenset(cl.ancestors(targetrevs, inclusive=True))
2321
2322 newrevs = list(alltargetrevs.difference(allbaserevs))
2323 newrevs.sort()
2324
2325 msg = b'benchmark of branchmap with %d revisions with %d new ones\n'
2326 ui.status(msg % (len(allbaserevs), len(newrevs)))
2327
2328 base = branchmap.branchcache()
2329 base.update(repo, allbaserevs)
2330
2331 def setup():
2332 x[0] = base.copy()
2333
2334 def bench():
2335 x[0].update(repo, newrevs)
2336
2337 timer(bench, setup=setup)
2338 fm.end()
2339
2285 @command(b'perfbranchmapload', [ 2340 @command(b'perfbranchmapload', [
2286 (b'f', b'filter', b'', b'Specify repoview filter'), 2341 (b'f', b'filter', b'', b'Specify repoview filter'),
2287 (b'', b'list', False, b'List brachmap filter caches'), 2342 (b'', b'list', False, b'List brachmap filter caches'),
2288 (b'', b'clear-revlogs', False, b'refresh changelog and manifest'), 2343 (b'', b'clear-revlogs', False, b'refresh changelog and manifest'),
2289 2344