##// END OF EJS Templates
perf: add perfbranchmap command...
Pierre-Yves David -
r18304:9b6ae29d default
parent child Browse files
Show More
@@ -2,7 +2,7 b''
2 2 '''helper extension to measure performance'''
3 3
4 4 from mercurial import cmdutil, scmutil, util, match, commands, obsolete
5 from mercurial import repoview
5 from mercurial import repoview, branchmap
6 6 import time, os, sys
7 7
8 8 cmdtable = {}
@@ -309,3 +309,58 b' def perfvolatilesets(ui, repo, *names):'
309 309
310 310 for name in allfilter:
311 311 timer(getfiltered(name), title=name)
312
313 @command('perfbranchmap',
314 [('f', 'full', False,
315 'Includes build time of subset'),
316 ])
317 def perfbranchmap(ui, repo, full=False):
318 """benchmark the update of a branchmap
319
320 This benchmarks the full repo.branchmap() call with read and write disabled
321 """
322 def getbranchmap(filtername):
323 """generate a benchmark function for the filtername"""
324 if filtername is None:
325 view = repo
326 else:
327 view = repo.filtered(filtername)
328 def d():
329 if full:
330 view._branchcaches.clear()
331 else:
332 view._branchcaches.pop(filtername, None)
333 view.branchmap()
334 return d
335 # add filter in smaller subset to bigger subset
336 possiblefilters = set(repoview.filtertable)
337 allfilters = []
338 while possiblefilters:
339 for name in possiblefilters:
340 subset = repoview.subsettable.get(name)
341 if subset not in possiblefilters:
342 break
343 else:
344 assert False, 'subset cycle %s!' % possiblefilters
345 allfilters.append(name)
346 possiblefilters.remove(name)
347
348 # warm the cache
349 if not full:
350 for name in allfilters:
351 repo.filtered(name).branchmap()
352 # add unfiltered
353 allfilters.append(None)
354 oldread = branchmap.read
355 oldwrite = branchmap.branchcache.write
356 try:
357 branchmap.read = lambda repo: None
358 branchmap.write = lambda repo: None
359 for name in allfilters:
360 timer(getbranchmap(name), title=str(name))
361 finally:
362 branchmap.read = oldread
363 branchmap.branchcache.write = oldwrite
364
365
366
General Comments 0
You need to be logged in to leave comments. Login now