Mercurial > hg
comparison contrib/perf.py @ 41438:e9891c734bf8
perf: add a no-lookup variant to perfindex
It is useful to check how long it takes to create a index object without doing
anything with it. We add a new flag dedicated to that.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Fri, 25 Jan 2019 18:43:48 -0500 |
parents | d65ba1ff4559 |
children | 7eb7637e34bf |
comparison
equal
deleted
inserted
replaced
41437:d65ba1ff4559 | 41438:e9891c734bf8 |
---|---|
1013 timer(runone, setup=setupone, title=b"load") | 1013 timer(runone, setup=setupone, title=b"load") |
1014 fm.end() | 1014 fm.end() |
1015 | 1015 |
1016 @command(b'perfindex', [ | 1016 @command(b'perfindex', [ |
1017 (b'', b'rev', b'', b'revision to be looked up (default tip)'), | 1017 (b'', b'rev', b'', b'revision to be looked up (default tip)'), |
1018 (b'', b'no-lookup', None, b'do not revision lookup post creation'), | |
1018 ] + formatteropts) | 1019 ] + formatteropts) |
1019 def perfindex(ui, repo, **opts): | 1020 def perfindex(ui, repo, **opts): |
1020 """benchmark index creation time followed by a lookup | 1021 """benchmark index creation time followed by a lookup |
1021 | 1022 |
1022 The default is to look `tip` up. Depending on the index implementation, | 1023 The default is to look `tip` up. Depending on the index implementation, |
1027 It is not currently possible to check for lookup of a missing node.""" | 1028 It is not currently possible to check for lookup of a missing node.""" |
1028 import mercurial.revlog | 1029 import mercurial.revlog |
1029 opts = _byteskwargs(opts) | 1030 opts = _byteskwargs(opts) |
1030 timer, fm = gettimer(ui, opts) | 1031 timer, fm = gettimer(ui, opts) |
1031 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | 1032 mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
1032 if opts[b'rev'] is None: | 1033 if opts[b'no_lookup']: |
1034 n = None | |
1035 elif opts[b'rev'] is None: | |
1033 n = repo[b"tip"].node() | 1036 n = repo[b"tip"].node() |
1034 else: | 1037 else: |
1035 rev = scmutil.revsingle(repo, opts[b'rev']) | 1038 rev = scmutil.revsingle(repo, opts[b'rev']) |
1036 n = repo[rev].node() | 1039 n = repo[rev].node() |
1037 | 1040 |
1042 def setup(): | 1045 def setup(): |
1043 # probably not necessary, but for good measure | 1046 # probably not necessary, but for good measure |
1044 clearchangelog(unfi) | 1047 clearchangelog(unfi) |
1045 def d(): | 1048 def d(): |
1046 cl = makecl(unfi) | 1049 cl = makecl(unfi) |
1047 cl.rev(n) | 1050 if n is not None: |
1051 cl.rev(n) | |
1048 timer(d, setup=setup) | 1052 timer(d, setup=setup) |
1049 fm.end() | 1053 fm.end() |
1050 | 1054 |
1051 @command(b'perfstartup', formatteropts) | 1055 @command(b'perfstartup', formatteropts) |
1052 def perfstartup(ui, repo, **opts): | 1056 def perfstartup(ui, repo, **opts): |