contrib/perf.py
changeset 32228 112ba1c7d65d
parent 32225 c68c400d0a2d
child 32229 75e93d95aae6
equal deleted inserted replaced
32227:1395f843ece4 32228:112ba1c7d65d
   885     chunks in a revlog. It effectively isolates I/O and compression performance.
   885     chunks in a revlog. It effectively isolates I/O and compression performance.
   886     For measurements of higher-level operations like resolving revisions,
   886     For measurements of higher-level operations like resolving revisions,
   887     see ``perfrevlog`` and ``perfrevlogrevision``.
   887     see ``perfrevlog`` and ``perfrevlogrevision``.
   888     """
   888     """
   889     rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts)
   889     rl = cmdutil.openrevlog(repo, 'perfrevlogchunks', file_, opts)
       
   890     segmentforrevs = rl._chunkraw
   890 
   891 
   891     # Verify engines argument.
   892     # Verify engines argument.
   892     if engines:
   893     if engines:
   893         engines = set(e.strip() for e in engines.split(','))
   894         engines = set(e.strip() for e in engines.split(','))
   894         for engine in engines:
   895         for engine in engines:
   916             return getsvfs(repo)(rl.datafile)
   917             return getsvfs(repo)(rl.datafile)
   917 
   918 
   918     def doread():
   919     def doread():
   919         rl.clearcaches()
   920         rl.clearcaches()
   920         for rev in revs:
   921         for rev in revs:
   921             rl._chunkraw(rev, rev)
   922             segmentforrevs(rev, rev)
   922 
   923 
   923     def doreadcachedfh():
   924     def doreadcachedfh():
   924         rl.clearcaches()
   925         rl.clearcaches()
   925         fh = rlfh(rl)
   926         fh = rlfh(rl)
   926         for rev in revs:
   927         for rev in revs:
   927             rl._chunkraw(rev, rev, df=fh)
   928             segmentforrevs(rev, rev, df=fh)
   928 
   929 
   929     def doreadbatch():
   930     def doreadbatch():
   930         rl.clearcaches()
   931         rl.clearcaches()
   931         rl._chunkraw(revs[0], revs[-1])
   932         segmentforrevs(revs[0], revs[-1])
   932 
   933 
   933     def doreadbatchcachedfh():
   934     def doreadbatchcachedfh():
   934         rl.clearcaches()
   935         rl.clearcaches()
   935         fh = rlfh(rl)
   936         fh = rlfh(rl)
   936         rl._chunkraw(revs[0], revs[-1], df=fh)
   937         segmentforrevs(revs[0], revs[-1], df=fh)
   937 
   938 
   938     def dochunk():
   939     def dochunk():
   939         rl.clearcaches()
   940         rl.clearcaches()
   940         fh = rlfh(rl)
   941         fh = rlfh(rl)
   941         for rev in revs:
   942         for rev in revs:
  1000         file_, rev = None, file_
  1001         file_, rev = None, file_
  1001     elif rev is None:
  1002     elif rev is None:
  1002         raise error.CommandError('perfrevlogrevision', 'invalid arguments')
  1003         raise error.CommandError('perfrevlogrevision', 'invalid arguments')
  1003 
  1004 
  1004     r = cmdutil.openrevlog(repo, 'perfrevlogrevision', file_, opts)
  1005     r = cmdutil.openrevlog(repo, 'perfrevlogrevision', file_, opts)
       
  1006     segmentforrevs = r._chunkraw
  1005     node = r.lookup(rev)
  1007     node = r.lookup(rev)
  1006     rev = r.rev(node)
  1008     rev = r.rev(node)
  1007 
  1009 
  1008     def getrawchunks(data, chain):
  1010     def getrawchunks(data, chain):
  1009         start = r.start
  1011         start = r.start
  1031         r._deltachain(rev)
  1033         r._deltachain(rev)
  1032 
  1034 
  1033     def doread(chain):
  1035     def doread(chain):
  1034         if not cache:
  1036         if not cache:
  1035             r.clearcaches()
  1037             r.clearcaches()
  1036         r._chunkraw(chain[0], chain[-1])
  1038         segmentforrevs(chain[0], chain[-1])
  1037 
  1039 
  1038     def dorawchunks(data, chain):
  1040     def dorawchunks(data, chain):
  1039         if not cache:
  1041         if not cache:
  1040             r.clearcaches()
  1042             r.clearcaches()
  1041         getrawchunks(data, chain)
  1043         getrawchunks(data, chain)
  1059         if not cache:
  1061         if not cache:
  1060             r.clearcaches()
  1062             r.clearcaches()
  1061         r.revision(node)
  1063         r.revision(node)
  1062 
  1064 
  1063     chain = r._deltachain(rev)[0]
  1065     chain = r._deltachain(rev)[0]
  1064     data = r._chunkraw(chain[0], chain[-1])[1]
  1066     data = segmentforrevs(chain[0], chain[-1])[1]
  1065     rawchunks = getrawchunks(data, chain)
  1067     rawchunks = getrawchunks(data, chain)
  1066     bins = r._chunks(chain)
  1068     bins = r._chunks(chain)
  1067     text = str(bins[0])
  1069     text = str(bins[0])
  1068     bins = bins[1:]
  1070     bins = bins[1:]
  1069     text = mdiff.patches(text, bins)
  1071     text = mdiff.patches(text, bins)