mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
treemanifest: log findrecenttrees time
Summary: `findrecenttrees` can take very long in my case - it only tests 1280 trees in 30 seconds. Log it so we can get some ideas about how long it takes. As we're here, teach `util.timefunction` to figure out the `ui` object automatically. Reviewed By: xavierd Differential Revision: D17066278 fbshipit-source-id: 7e59c8683359a7ce8d4e87fde92af36b95d37b2f
This commit is contained in:
parent
5def63525a
commit
925ef09146
@ -2186,6 +2186,7 @@ def _postpullprefetch(ui, repo):
|
||||
repo.prefetchtrees(mfnodes, basemfnodes=basemfnodes)
|
||||
|
||||
|
||||
@util.timefunction("findrecenttrees")
|
||||
def _findrecenttree(repo, startrev, targetmfnodes):
|
||||
cl = repo.changelog
|
||||
mfstore = repo.manifestlog.datastore
|
||||
|
@ -4310,7 +4310,7 @@ class ring(object):
|
||||
return head + tail
|
||||
|
||||
|
||||
def timefunction(key, uiposition, uiname):
|
||||
def timefunction(key, uiposition=None, uiname=None):
|
||||
"""A decorator for indicating a function should be timed and logged.
|
||||
|
||||
`uiposition` the integer argument number that contains the ui or a reference
|
||||
@ -4327,9 +4327,20 @@ def timefunction(key, uiposition, uiname):
|
||||
|
||||
def wrapper(func):
|
||||
def inner(*args, **kwargs):
|
||||
uiarg = args[uiposition]
|
||||
uiarg = None
|
||||
if uiposition is not None:
|
||||
uiarg = args[uiposition]
|
||||
if uiname is not None:
|
||||
uiarg = getattr(uiarg, uiname)
|
||||
if uiarg is None:
|
||||
for arg in list(args) + list(kwargs.values()):
|
||||
if safehasattr(arg, "timesection"):
|
||||
uiarg = arg
|
||||
break
|
||||
elif safehasattr(arg, "ui"):
|
||||
uiarg = arg.ui
|
||||
break
|
||||
assert uiarg
|
||||
with uiarg.timesection(key):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user