##// END OF EJS Templates
extension: add a summary of total loading time per extension...
Boris Feld -
r39547:1ab185c7 default
parent child Browse files
Show More
@@ -166,7 +166,7 b' def _validatetables(ui, mod):'
166 _rejectunicode(t, o._table)
166 _rejectunicode(t, o._table)
167 _validatecmdtable(ui, getattr(mod, 'cmdtable', {}))
167 _validatecmdtable(ui, getattr(mod, 'cmdtable', {}))
168
168
169 def load(ui, name, path, log=lambda *a: None):
169 def load(ui, name, path, log=lambda *a: None, loadingtime=None):
170 if name.startswith('hgext.') or name.startswith('hgext/'):
170 if name.startswith('hgext.') or name.startswith('hgext/'):
171 shortname = name[6:]
171 shortname = name[6:]
172 else:
172 else:
@@ -180,6 +180,8 b' def load(ui, name, path, log=lambda *a: '
180 with util.timedcm('load extension %r', shortname) as stats:
180 with util.timedcm('load extension %r', shortname) as stats:
181 mod = _importext(name, path, bind(_reportimporterror, ui))
181 mod = _importext(name, path, bind(_reportimporterror, ui))
182 log(' > %r extension loaded in %s\n', shortname, stats)
182 log(' > %r extension loaded in %s\n', shortname, stats)
183 if loadingtime is not None:
184 loadingtime[shortname] += stats.elapsed
183
185
184 # Before we do anything with the extension, check against minimum stated
186 # Before we do anything with the extension, check against minimum stated
185 # compatibility. This gives extension authors a mechanism to have their
187 # compatibility. This gives extension authors a mechanism to have their
@@ -237,6 +239,7 b' def loadall(ui, whitelist=None):'
237 msg % values, label='debug.extensions')
239 msg % values, label='debug.extensions')
238 else:
240 else:
239 log = lambda *a, **kw: None
241 log = lambda *a, **kw: None
242 loadingtime = collections.defaultdict(int)
240 result = ui.configitems("extensions")
243 result = ui.configitems("extensions")
241 if whitelist is not None:
244 if whitelist is not None:
242 result = [(k, v) for (k, v) in result if k in whitelist]
245 result = [(k, v) for (k, v) in result if k in whitelist]
@@ -252,7 +255,7 b' def loadall(ui, whitelist=None):'
252 _disabledextensions[name] = path[1:]
255 _disabledextensions[name] = path[1:]
253 continue
256 continue
254 try:
257 try:
255 load(ui, name, path, log)
258 load(ui, name, path, log, loadingtime)
256 except Exception as inst:
259 except Exception as inst:
257 msg = stringutil.forcebytestr(inst)
260 msg = stringutil.forcebytestr(inst)
258 if path:
261 if path:
@@ -292,6 +295,7 b' def loadall(ui, whitelist=None):'
292 log(' - the %r extension uisetup failed\n', name)
295 log(' - the %r extension uisetup failed\n', name)
293 broken.add(name)
296 broken.add(name)
294 log(' > uisetup for %r took %s\n', name, stats)
297 log(' > uisetup for %r took %s\n', name, stats)
298 loadingtime[name] += stats.elapsed
295 log('> all uisetup took %s\n', alluisetupstats)
299 log('> all uisetup took %s\n', alluisetupstats)
296
300
297 log('- executing extsetup hooks\n')
301 log('- executing extsetup hooks\n')
@@ -305,6 +309,7 b' def loadall(ui, whitelist=None):'
305 log(' - the %r extension extsetup failed\n', name)
309 log(' - the %r extension extsetup failed\n', name)
306 broken.add(name)
310 broken.add(name)
307 log(' > extsetup for %r took %s\n', name, stats)
311 log(' > extsetup for %r took %s\n', name, stats)
312 loadingtime[name] += stats.elapsed
308 log('> all extsetup took %s\n', allextetupstats)
313 log('> all extsetup took %s\n', allextetupstats)
309
314
310 for name in broken:
315 for name in broken:
@@ -360,6 +365,12 b' def loadall(ui, whitelist=None):'
360 with util.timedcm('load registration objects') as stats:
365 with util.timedcm('load registration objects') as stats:
361 _loadextra(ui, newindex, extraloaders)
366 _loadextra(ui, newindex, extraloaders)
362 log('> extension registration object loading took %s\n', stats)
367 log('> extension registration object loading took %s\n', stats)
368
369 # Report per extension loading time (except reposetup)
370 for name in sorted(loadingtime):
371 extension_msg = '> extension %s take a total of %s to load\n'
372 log(extension_msg, name, util.timecount(loadingtime[name]))
373
363 log('extension loading complete\n')
374 log('extension loading complete\n')
364
375
365 def _loadextra(ui, newindex, extraloaders):
376 def _loadextra(ui, newindex, extraloaders):
@@ -122,6 +122,8 b' show traceback for ImportError of hgext.'
122 debug.extensions: > remaining aftercallbacks completed in * (glob)
122 debug.extensions: > remaining aftercallbacks completed in * (glob)
123 debug.extensions: - loading extension registration objects
123 debug.extensions: - loading extension registration objects
124 debug.extensions: > extension registration object loading took * (glob)
124 debug.extensions: > extension registration object loading took * (glob)
125 debug.extensions: > extension baddocext take a total of * to load (glob)
126 debug.extensions: > extension gpg take a total of * to load (glob)
125 debug.extensions: extension loading complete
127 debug.extensions: extension loading complete
126 #endif
128 #endif
127
129
@@ -68,6 +68,7 b' Test extension setup timings'
68 debug.extensions: > remaining aftercallbacks completed in * (glob)
68 debug.extensions: > remaining aftercallbacks completed in * (glob)
69 debug.extensions: - loading extension registration objects
69 debug.extensions: - loading extension registration objects
70 debug.extensions: > extension registration object loading took * (glob)
70 debug.extensions: > extension registration object loading took * (glob)
71 debug.extensions: > extension foobar take a total of * to load (glob)
71 debug.extensions: extension loading complete
72 debug.extensions: extension loading complete
72 debug.extensions: loading additional extensions
73 debug.extensions: loading additional extensions
73 debug.extensions: - processing 1 entries
74 debug.extensions: - processing 1 entries
General Comments 0
You need to be logged in to leave comments. Login now