contrib/perf.py
changeset 42942 adac17faa72e
parent 42941 3a1ad3aeb64a
child 42979 b4093d1d3b18
equal deleted inserted replaced
42941:3a1ad3aeb64a 42942:adac17faa72e
  1743 
  1743 
  1744 @command(b'perfhelper-pathcopies', formatteropts +
  1744 @command(b'perfhelper-pathcopies', formatteropts +
  1745          [
  1745          [
  1746           (b'r', b'revs', [], b'restrict search to these revisions'),
  1746           (b'r', b'revs', [], b'restrict search to these revisions'),
  1747           (b'', b'timing', False, b'provides extra data (costly)'),
  1747           (b'', b'timing', False, b'provides extra data (costly)'),
       
  1748           (b'', b'stats', False, b'provides statistic about the measured data'),
  1748          ])
  1749          ])
  1749 def perfhelperpathcopies(ui, repo, revs=[], **opts):
  1750 def perfhelperpathcopies(ui, repo, revs=[], **opts):
  1750     """find statistic about potential parameters for the `perftracecopies`
  1751     """find statistic about potential parameters for the `perftracecopies`
  1751 
  1752 
  1752     This command find source-destination pair relevant for copytracing testing.
  1753     This command find source-destination pair relevant for copytracing testing.
  1761     approximation of which revision pairs are very costly.
  1762     approximation of which revision pairs are very costly.
  1762     """
  1763     """
  1763     opts = _byteskwargs(opts)
  1764     opts = _byteskwargs(opts)
  1764     fm = ui.formatter(b'perf', opts)
  1765     fm = ui.formatter(b'perf', opts)
  1765     dotiming = opts[b'timing']
  1766     dotiming = opts[b'timing']
       
  1767     dostats = opts[b'stats']
  1766 
  1768 
  1767     if dotiming:
  1769     if dotiming:
  1768         header = '%12s %12s %12s %12s %12s %12s\n'
  1770         header = '%12s %12s %12s %12s %12s %12s\n'
  1769         output = ("%(source)12s %(destination)12s "
  1771         output = ("%(source)12s %(destination)12s "
  1770                   "%(nbrevs)12d %(nbmissingfiles)12d "
  1772                   "%(nbrevs)12d %(nbmissingfiles)12d "
  1779         fm.plain(header % ("source", "destination", "nb-revs", "nb-files"))
  1781         fm.plain(header % ("source", "destination", "nb-revs", "nb-files"))
  1780 
  1782 
  1781     if not revs:
  1783     if not revs:
  1782         revs = ['all()']
  1784         revs = ['all()']
  1783     revs = scmutil.revrange(repo, revs)
  1785     revs = scmutil.revrange(repo, revs)
       
  1786 
       
  1787 
       
  1788     if dostats:
       
  1789         alldata = {
       
  1790             'nbrevs': [],
       
  1791             'nbmissingfiles': [],
       
  1792         }
       
  1793         if dotiming:
       
  1794             alldata['nbrenames'] = []
       
  1795             alldata['time'] = []
  1784 
  1796 
  1785     roi = repo.revs('merge() and %ld', revs)
  1797     roi = repo.revs('merge() and %ld', revs)
  1786     for r in roi:
  1798     for r in roi:
  1787         ctx = repo[r]
  1799         ctx = repo[r]
  1788         p1 = ctx.p1().rev()
  1800         p1 = ctx.p1().rev()
  1799                     b'source': base.hex(),
  1811                     b'source': base.hex(),
  1800                     b'destination': parent.hex(),
  1812                     b'destination': parent.hex(),
  1801                     b'nbrevs': len(repo.revs('%d::%d', b, p)),
  1813                     b'nbrevs': len(repo.revs('%d::%d', b, p)),
  1802                     b'nbmissingfiles': len(missing),
  1814                     b'nbmissingfiles': len(missing),
  1803                 }
  1815                 }
       
  1816                 alldata['nbrevs'].append((
       
  1817                     data['nbrevs'],
       
  1818                     base.hex(),
       
  1819                     parent.hex(),
       
  1820                 ))
       
  1821                 alldata['nbmissingfiles'].append((
       
  1822                     data['nbmissingfiles'],
       
  1823                     base.hex(),
       
  1824                     parent.hex(),
       
  1825                 ))
  1804                 if dotiming:
  1826                 if dotiming:
  1805                     begin = util.timer()
  1827                     begin = util.timer()
  1806                     renames = copies.pathcopies(base, parent)
  1828                     renames = copies.pathcopies(base, parent)
  1807                     end = util.timer()
  1829                     end = util.timer()
  1808                     # not very stable timing since we did only one run
  1830                     # not very stable timing since we did only one run
  1809                     data['time'] = end - begin
  1831                     data['time'] = end - begin
  1810                     data['nbrenamedfiles'] = len(renames)
  1832                     data['nbrenamedfiles'] = len(renames)
       
  1833                     alldata['time'].append((
       
  1834                         data['time'],
       
  1835                         base.hex(),
       
  1836                         parent.hex(),
       
  1837                     ))
       
  1838                     alldata['nbrenames'].append((
       
  1839                         data['nbrenamedfiles'],
       
  1840                         base.hex(),
       
  1841                         parent.hex(),
       
  1842                     ))
  1811                 fm.startitem()
  1843                 fm.startitem()
  1812                 fm.data(**data)
  1844                 fm.data(**data)
  1813                 out = data.copy()
  1845                 out = data.copy()
  1814                 out['source'] = fm.hexfunc(base.node())
  1846                 out['source'] = fm.hexfunc(base.node())
  1815                 out['destination'] = fm.hexfunc(parent.node())
  1847                 out['destination'] = fm.hexfunc(parent.node())
  1816                 fm.plain(output % out)
  1848                 fm.plain(output % out)
  1817 
  1849 
  1818     fm.end()
  1850     fm.end()
       
  1851     if dostats:
       
  1852         # use a second formatter because the data are quite different, not sure
       
  1853         # how it flies with the templater.
       
  1854         fm = ui.formatter(b'perf', opts)
       
  1855         entries = [
       
  1856             ('nbrevs', 'number of revision covered'),
       
  1857             ('nbmissingfiles', 'number of missing files at head'),
       
  1858         ]
       
  1859         if dotiming:
       
  1860             entries.append(('nbrenames',
       
  1861                             'renamed files'))
       
  1862             entries.append(('time', 'time'))
       
  1863         _displaystats(ui, opts, entries, alldata)
  1819 
  1864 
  1820 @command(b'perfcca', formatteropts)
  1865 @command(b'perfcca', formatteropts)
  1821 def perfcca(ui, repo, **opts):
  1866 def perfcca(ui, repo, **opts):
  1822     opts = _byteskwargs(opts)
  1867     opts = _byteskwargs(opts)
  1823     timer, fm = gettimer(ui, opts)
  1868     timer, fm = gettimer(ui, opts)