comparison contrib/perf.py @ 40554:6c2357029364

perf: add `parent-1` as possible source for perfrevlogwrite This source will use a diff against p1 in all case.
author Boris Feld <boris.feld@octobus.net>
date Mon, 05 Nov 2018 15:15:02 +0100
parents 631011ff6771
children b5b3dd4e40c3
comparison
equal deleted inserted replaced
40553:631011ff6771 40554:6c2357029364
1578 def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts): 1578 def perfrevlogwrite(ui, repo, file_=None, startrev=1000, stoprev=-1, **opts):
1579 """Benchmark writing a series of revisions to a revlog. 1579 """Benchmark writing a series of revisions to a revlog.
1580 1580
1581 Possible source values are: 1581 Possible source values are:
1582 * `full`: add from a full text (default). 1582 * `full`: add from a full text (default).
1583 * `parent-1`: add from a delta to the first parent
1583 """ 1584 """
1584 opts = _byteskwargs(opts) 1585 opts = _byteskwargs(opts)
1585 1586
1586 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts) 1587 rl = cmdutil.openrevlog(repo, b'perfrevlogwrite', file_, opts)
1587 rllen = getlen(ui)(rl) 1588 rllen = getlen(ui)(rl)
1589 startrev = rllen + startrev 1590 startrev = rllen + startrev
1590 if stoprev < 0: 1591 if stoprev < 0:
1591 stoprev = rllen + stoprev 1592 stoprev = rllen + stoprev
1592 1593
1593 source = opts['source'] 1594 source = opts['source']
1594 validsource = (b'full',) 1595 validsource = (b'full', b'parent-1')
1595 if source not in validsource: 1596 if source not in validsource:
1596 raise error.Abort('invalid source type: %s' % source) 1597 raise error.Abort('invalid source type: %s' % source)
1597 1598
1598 ### actually gather results 1599 ### actually gather results
1599 count = opts['count'] 1600 count = opts['count']
1691 cachedelta = None 1692 cachedelta = None
1692 text = None 1693 text = None
1693 1694
1694 if source == b'full': 1695 if source == b'full':
1695 text = orig.revision(rev) 1696 text = orig.revision(rev)
1697 elif source == b'parent-1':
1698 baserev = orig.rev(p1)
1699 cachedelta = (baserev, orig.revdiff(p1, rev))
1696 1700
1697 return ((text, tr, linkrev, p1, p2), 1701 return ((text, tr, linkrev, p1, p2),
1698 {'node': node, 'flags': flags, 'cachedelta': cachedelta}) 1702 {'node': node, 'flags': flags, 'cachedelta': cachedelta})
1699 1703
1700 @contextlib.contextmanager 1704 @contextlib.contextmanager