contrib/perf.py
changeset 30017 973cf6c3de30
parent 29567 7e2b389418da
child 30018 bd6df07ccc24
equal deleted inserted replaced
30016:2963fba2d18a 30017:973cf6c3de30
   578         timer(d, title)
   578         timer(d, title)
   579     fm.end()
   579     fm.end()
   580 
   580 
   581 @command('perfrevlog', revlogopts + formatteropts +
   581 @command('perfrevlog', revlogopts + formatteropts +
   582          [('d', 'dist', 100, 'distance between the revisions'),
   582          [('d', 'dist', 100, 'distance between the revisions'),
   583           ('s', 'startrev', 0, 'revision to start reading at')],
   583           ('s', 'startrev', 0, 'revision to start reading at'),
       
   584           ('', 'reverse', False, 'read in reverse')],
   584          '-c|-m|FILE')
   585          '-c|-m|FILE')
   585 def perfrevlog(ui, repo, file_=None, startrev=0, **opts):
   586 def perfrevlog(ui, repo, file_=None, startrev=0, reverse=False, **opts):
   586     """Benchmark reading a series of revisions from a revlog.
   587     """Benchmark reading a series of revisions from a revlog.
   587 
   588 
   588     By default, we read every ``-d/--dist`` revision from 0 to tip of
   589     By default, we read every ``-d/--dist`` revision from 0 to tip of
   589     the specified revlog.
   590     the specified revlog.
   590 
   591 
   591     The start revision can be defined via ``-s/--startrev``.
   592     The start revision can be defined via ``-s/--startrev``.
   592     """
   593     """
   593     timer, fm = gettimer(ui, opts)
   594     timer, fm = gettimer(ui, opts)
   594     dist = opts['dist']
       
   595     _len = getlen(ui)
   595     _len = getlen(ui)
       
   596 
   596     def d():
   597     def d():
   597         r = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts)
   598         r = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts)
   598         for x in xrange(startrev, _len(r), dist):
   599 
       
   600         startrev = 0
       
   601         endrev = _len(r)
       
   602         dist = opts['dist']
       
   603 
       
   604         if reverse:
       
   605             startrev, endrev = endrev, startrev
       
   606             dist = -1 * dist
       
   607 
       
   608         for x in xrange(startrev, endrev, dist):
   599             r.revision(r.node(x))
   609             r.revision(r.node(x))
   600 
   610 
   601     timer(d)
   611     timer(d)
   602     fm.end()
   612     fm.end()
   603 
   613