contrib/perf.py
changeset 40806 5cbb74999040
parent 40805 58355a1de6b3
child 40817 e207f0d6c243
equal deleted inserted replaced
40805:58355a1de6b3 40806:5cbb74999040
  2283     fm.end()
  2283     fm.end()
  2284 
  2284 
  2285 @command(b'perfbranchmapupdate', [
  2285 @command(b'perfbranchmapupdate', [
  2286      (b'', b'base', [], b'subset of revision to start from'),
  2286      (b'', b'base', [], b'subset of revision to start from'),
  2287      (b'', b'target', [], b'subset of revision to end with'),
  2287      (b'', b'target', [], b'subset of revision to end with'),
       
  2288      (b'', b'clear-caches', False, b'clear cache between each runs')
  2288     ] + formatteropts)
  2289     ] + formatteropts)
  2289 def perfbranchmapupdate(ui, repo, base=(), target=(), **opts):
  2290 def perfbranchmapupdate(ui, repo, base=(), target=(), **opts):
  2290     """benchmark branchmap update from for <base> revs to <target> revs
  2291     """benchmark branchmap update from for <base> revs to <target> revs
       
  2292 
       
  2293     If `--clear-caches` is passed, the following items will be reset before
       
  2294     each update:
       
  2295         * the changelog instance and associated indexes
       
  2296         * the rev-branch-cache instance
  2291 
  2297 
  2292     Examples:
  2298     Examples:
  2293 
  2299 
  2294        # update for the one last revision
  2300        # update for the one last revision
  2295        $ hg perfbranchmapupdate --base 'not tip' --target 'tip'
  2301        $ hg perfbranchmapupdate --base 'not tip' --target 'tip'
  2299     """
  2305     """
  2300     from mercurial import branchmap
  2306     from mercurial import branchmap
  2301     from mercurial import repoview
  2307     from mercurial import repoview
  2302     opts = _byteskwargs(opts)
  2308     opts = _byteskwargs(opts)
  2303     timer, fm = gettimer(ui, opts)
  2309     timer, fm = gettimer(ui, opts)
       
  2310     clearcaches = opts[b'clear_caches']
  2304     unfi = repo.unfiltered()
  2311     unfi = repo.unfiltered()
  2305     x = [None] # used to pass data between closure
  2312     x = [None] # used to pass data between closure
  2306 
  2313 
  2307     # we use a `list` here to avoid possible side effect from smartset
  2314     # we use a `list` here to avoid possible side effect from smartset
  2308     baserevs = list(scmutil.revrange(repo, base))
  2315     baserevs = list(scmutil.revrange(repo, base))
  2364             base = branchmap.branchcache()
  2371             base = branchmap.branchcache()
  2365             base.update(baserepo, allbaserevs)
  2372             base.update(baserepo, allbaserevs)
  2366 
  2373 
  2367         def setup():
  2374         def setup():
  2368             x[0] = base.copy()
  2375             x[0] = base.copy()
       
  2376             if clearcaches:
       
  2377                 unfi._revbranchcache = None
       
  2378                 clearchangelog(repo)
  2369 
  2379 
  2370         def bench():
  2380         def bench():
  2371             x[0].update(targetrepo, newrevs)
  2381             x[0].update(targetrepo, newrevs)
  2372 
  2382 
  2373         timer(bench, setup=setup)
  2383         timer(bench, setup=setup)