comparison contrib/perf.py @ 36360:c25290b98190

perfbranchmap: allow to select the filter to benchmark Running the branchmap computation on all filter levels can be expensive. Narrowing the run to some specific filters can speed up benchmarking time when working only on a subset of filter levels.
author Boris Feld <boris.feld@octobus.net>
date Wed, 21 Feb 2018 11:43:12 +0100
parents df3f7f00a3fc
children d382344c69aa
comparison
equal deleted inserted replaced
36359:df3f7f00a3fc 36360:c25290b98190
1566 [('f', 'full', False, 1566 [('f', 'full', False,
1567 'Includes build time of subset'), 1567 'Includes build time of subset'),
1568 ('', 'clear-revbranch', False, 1568 ('', 'clear-revbranch', False,
1569 'purge the revbranch cache between computation'), 1569 'purge the revbranch cache between computation'),
1570 ] + formatteropts) 1570 ] + formatteropts)
1571 def perfbranchmap(ui, repo, full=False, clear_revbranch=False, **opts): 1571 def perfbranchmap(ui, repo, *filternames, **opts):
1572 """benchmark the update of a branchmap 1572 """benchmark the update of a branchmap
1573 1573
1574 This benchmarks the full repo.branchmap() call with read and write disabled 1574 This benchmarks the full repo.branchmap() call with read and write disabled
1575 """ 1575 """
1576 full = opts.get("full", False)
1577 clear_revbranch = opts.get("clear_revbranch", False)
1576 timer, fm = gettimer(ui, opts) 1578 timer, fm = gettimer(ui, opts)
1577 def getbranchmap(filtername): 1579 def getbranchmap(filtername):
1578 """generate a benchmark function for the filtername""" 1580 """generate a benchmark function for the filtername"""
1579 if filtername is None: 1581 if filtername is None:
1580 view = repo 1582 view = repo
1589 view._branchcaches.pop(filtername, None) 1591 view._branchcaches.pop(filtername, None)
1590 view.branchmap() 1592 view.branchmap()
1591 return d 1593 return d
1592 # add filter in smaller subset to bigger subset 1594 # add filter in smaller subset to bigger subset
1593 possiblefilters = set(repoview.filtertable) 1595 possiblefilters = set(repoview.filtertable)
1596 if filternames:
1597 possiblefilters &= set(filternames)
1594 subsettable = getbranchmapsubsettable() 1598 subsettable = getbranchmapsubsettable()
1595 allfilters = [] 1599 allfilters = []
1596 while possiblefilters: 1600 while possiblefilters:
1597 for name in possiblefilters: 1601 for name in possiblefilters:
1598 subset = subsettable.get(name) 1602 subset = subsettable.get(name)
1605 1609
1606 # warm the cache 1610 # warm the cache
1607 if not full: 1611 if not full:
1608 for name in allfilters: 1612 for name in allfilters:
1609 repo.filtered(name).branchmap() 1613 repo.filtered(name).branchmap()
1610 # add unfiltered 1614 if not filternames or 'unfiltered' in filternames:
1611 allfilters.append(None) 1615 # add unfiltered
1616 allfilters.append(None)
1612 1617
1613 branchcacheread = safeattrsetter(branchmap, 'read') 1618 branchcacheread = safeattrsetter(branchmap, 'read')
1614 branchcachewrite = safeattrsetter(branchmap.branchcache, 'write') 1619 branchcachewrite = safeattrsetter(branchmap.branchcache, 'write')
1615 branchcacheread.set(lambda repo: None) 1620 branchcacheread.set(lambda repo: None)
1616 branchcachewrite.set(lambda bc, repo: None) 1621 branchcachewrite.set(lambda bc, repo: None)