contrib/perf.py
changeset 49444 b081a5aab782
parent 49037 642e31cb55f0
child 49445 3635aae8b2e9
equal deleted inserted replaced
49443:2bbd7bc7d6c4 49444:b081a5aab782
   972 
   972 
   973     timer(d, setup=s)
   973     timer(d, setup=s)
   974     fm.end()
   974     fm.end()
   975 
   975 
   976 
   976 
       
   977 @command(b'perf::bundle', formatteropts, b'REVS')
       
   978 def perfbundle(ui, repo, *revs, **opts):
       
   979     """benchmark the creation of a bundle from a repository
       
   980 
       
   981     For now, this create a `none-v1` bundle.
       
   982     """
       
   983     from mercurial import bundlecaches
       
   984     from mercurial import discovery
       
   985     from mercurial import bundle2
       
   986 
       
   987     opts = _byteskwargs(opts)
       
   988     timer, fm = gettimer(ui, opts)
       
   989 
       
   990     cl = repo.changelog
       
   991     revs = scmutil.revrange(repo, revs)
       
   992     if not revs:
       
   993         raise error.Abort(b"not revision specified")
       
   994     # make it a consistent set (ie: without topological gaps)
       
   995     old_len = len(revs)
       
   996     revs = list(repo.revs(b"%ld::%ld", revs, revs))
       
   997     if old_len != len(revs):
       
   998         new_count = len(revs) - old_len
       
   999         msg = b"add %d new revisions to make it a consistent set\n"
       
  1000         ui.write_err(msg % new_count)
       
  1001 
       
  1002     targets = [cl.node(r) for r in repo.revs(b"heads(::%ld)", revs)]
       
  1003     bases = [cl.node(r) for r in repo.revs(b"heads(::%ld - %ld)", revs, revs)]
       
  1004     outgoing = discovery.outgoing(repo, bases, targets)
       
  1005 
       
  1006     bundlespec = bundlecaches.parsebundlespec(
       
  1007         repo, b"none", strict=False
       
  1008     )
       
  1009 
       
  1010     bversion = b'HG10' + bundlespec.wirecompression
       
  1011 
       
  1012     def do_bundle():
       
  1013         bundle2.writenewbundle(
       
  1014             ui,
       
  1015             repo,
       
  1016             b'perf::bundle',
       
  1017             os.devnull,
       
  1018             bversion,
       
  1019             outgoing,
       
  1020             {},
       
  1021         )
       
  1022 
       
  1023     timer(do_bundle)
       
  1024     fm.end()
       
  1025 
       
  1026 
   977 @command(b'perf::bundleread|perfbundleread', formatteropts, b'BUNDLE')
  1027 @command(b'perf::bundleread|perfbundleread', formatteropts, b'BUNDLE')
   978 def perfbundleread(ui, repo, bundlepath, **opts):
  1028 def perfbundleread(ui, repo, bundlepath, **opts):
   979     """Benchmark reading of bundle files.
  1029     """Benchmark reading of bundle files.
   980 
  1030 
   981     This command is meant to isolate the I/O part of bundle reading as
  1031     This command is meant to isolate the I/O part of bundle reading as