Mercurial > hg
comparison contrib/perf.py @ 32232:4c6b2076d292
perf: move revlog construction and length calculation out of benchmark
We don't need to measure the time it takes to open the revlog or
calculate its length.
This is more consistent with what other perf* functions do.
While I was here, I also renamed the revlog variable from "r" to
"rl" - again in the name of consistency.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 06 May 2017 11:16:59 -0700 |
parents | 954f63391d71 |
children | d7efaf6275a7 |
comparison
equal
deleted
inserted
replaced
32231:954f63391d71 | 32232:4c6b2076d292 |
---|---|
848 By default, we read every ``-d/--dist`` revision from 0 to tip of | 848 By default, we read every ``-d/--dist`` revision from 0 to tip of |
849 the specified revlog. | 849 the specified revlog. |
850 | 850 |
851 The start revision can be defined via ``-s/--startrev``. | 851 The start revision can be defined via ``-s/--startrev``. |
852 """ | 852 """ |
853 _len = getlen(ui) | 853 rl = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts) |
854 | 854 rllen = getlen(ui)(rl) |
855 def d(): | 855 |
856 r = cmdutil.openrevlog(repo, 'perfrevlog', file_, opts) | 856 def d(): |
857 r.clearcaches() | 857 rl.clearcaches() |
858 | 858 |
859 beginrev = startrev | 859 beginrev = startrev |
860 endrev = _len(r) | 860 endrev = rllen |
861 dist = opts['dist'] | 861 dist = opts['dist'] |
862 | 862 |
863 if reverse: | 863 if reverse: |
864 beginrev, endrev = endrev, beginrev | 864 beginrev, endrev = endrev, beginrev |
865 dist = -1 * dist | 865 dist = -1 * dist |
866 | 866 |
867 for x in xrange(beginrev, endrev, dist): | 867 for x in xrange(beginrev, endrev, dist): |
868 r.revision(x) | 868 rl.revision(x) |
869 | 869 |
870 timer, fm = gettimer(ui, opts) | 870 timer, fm = gettimer(ui, opts) |
871 timer(d) | 871 timer(d) |
872 fm.end() | 872 fm.end() |
873 | 873 |