tests/svnxml.py
author spectral <spectral@google.com>
Thu, 27 Sep 2018 20:16:48 -0700
changeset 39985 731961d972ba
parent 28947 812eb3b7dc43
child 40216 c17d73bf6a4d
permissions -rw-r--r--
treemanifests: remove _loadalllazy in _diff() The benchmarks below use a similar setup as in ee7ee0c516ca and my other recent commits. Yes, in some cases this runs in literally 5% of the time it previously took. before = a6f8ab53 diff --git: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 1.301 s +- 0.004 s | 1.309 s +- 0.012 s | 100.6% m-u | | x | 1.303 s +- 0.009 s | 1.302 s +- 0.006 s | 99.9% m-u | x | | 1.308 s +- 0.006 s | 1.309 s +- 0.007 s | 100.1% m-u | x | x | 85.7 ms +- 0.6 ms | 86.0 ms +- 0.3 ms | 100.4% l-d-r | | | 197.5 ms +- 0.7 ms | 197.8 ms +- 2.2 ms | 100.2% l-d-r | | x | 199.4 ms +- 0.6 ms | 199.3 ms +- 0.9 ms | 99.9% l-d-r | x | | 86.1 ms +- 0.5 ms | 85.8 ms +- 0.9 ms | 99.7% l-d-r | x | x | 64.4 ms +- 0.4 ms | 64.4 ms +- 0.3 ms | 100.0% diff -c . --git: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 236.7 ms +- 1.1 ms | 236.5 ms +- 1.3 ms | 99.9% m-u | | x | 158.7 ms +- 1.0 ms | 128.0 ms +- 1.0 ms | 80.7% <-- m-u | x | | 239.7 ms +- 1.8 ms | 238.1 ms +- 1.5 ms | 99.3% m-u | x | x | 132.4 ms +- 0.9 ms | 132.3 ms +- 0.6 ms | 99.9% l-d-r | | | 81.8 ms +- 0.4 ms | 81.8 ms +- 0.3 ms | 100.0% l-d-r | | x | 3.894 s +- 0.017 s | 193.6 ms +- 0.4 ms | 5.0% <-- l-d-r | x | | 106.9 ms +- 0.4 ms | 106.6 ms +- 0.3 ms | 99.7% l-d-r | x | x | 182.7 ms +- 0.8 ms | 183.3 ms +- 0.9 ms | 100.3% rebase -r . --keep -d .^^: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 5.615 s +- 0.109 s | 5.562 s +- 0.015 s | 99.1% m-u | | x | 5.701 s +- 0.027 s | 5.715 s +- 0.023 s | 100.2% m-u | x | | 5.572 s +- 0.128 s | 5.613 s +- 0.182 s | 100.7% m-u | x | x | 633.3 ms +- 28.7 ms | 636.2 ms +- 13.8 ms | 100.5% l-d-r | | | 666.4 ms +- 17.0 ms | 658.5 ms +- 9.3 ms | 98.8% l-d-r | | x | 6.520 s +- 0.070 s | 6.505 s +- 0.026 s | 99.8% l-d-r | x | | 279.0 ms +- 13.0 ms | 276.5 ms +- 4.7 ms | 99.1% l-d-r | x | x | 1.636 s +- 0.058 s | 1.657 s +- 0.014 s | 101.3% status --change . --copies: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 218.6 ms +- 1.4 ms | 217.9 ms +- 1.5 ms | 99.7% m-u | | x | 138.5 ms +- 0.4 ms | 108.4 ms +- 0.2 ms | 78.3% <-- m-u | x | | 220.1 ms +- 1.3 ms | 219.7 ms +- 1.5 ms | 99.8% m-u | x | x | 113.2 ms +- 0.4 ms | 112.4 ms +- 0.8 ms | 99.3% l-d-r | | | 80.2 ms +- 0.3 ms | 80.6 ms +- 0.6 ms | 100.5% l-d-r | | x | 3.899 s +- 0.020 s | 194.8 ms +- 4.0 ms | 5.0% <-- l-d-r | x | | 83.4 ms +- 0.8 ms | 83.2 ms +- 0.2 ms | 99.8% l-d-r | x | x | 732.2 ms +- 4.3 ms | 194.9 ms +- 1.0 ms | 26.6% <-- status --copies: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 1.917 s +- 0.005 s | 1.914 s +- 0.004 s | 99.8% m-u | | x | 1.909 s +- 0.012 s | 1.934 s +- 0.004 s | 101.3% m-u | x | | 1.915 s +- 0.005 s | 1.904 s +- 0.004 s | 99.4% m-u | x | x | 94.8 ms +- 0.3 ms | 94.7 ms +- 0.2 ms | 99.9% l-d-r | | | 593.9 ms +- 1.2 ms | 594.6 ms +- 9.4 ms | 100.1% l-d-r | | x | 595.2 ms +- 3.8 ms | 597.2 ms +- 2.6 ms | 100.3% l-d-r | x | | 182.5 ms +- 1.6 ms | 182.1 ms +- 0.6 ms | 99.8% l-d-r | x | x | 149.6 ms +- 0.9 ms | 149.1 ms +- 0.8 ms | 99.7% update $rev^; ~/src/hg/hg{hg}/hg update $rev: repo | N | T | before (mean +- stdev) | after (mean +- stdev) | % of before ------+---+---+------------------------+-----------------------+------------ m-u | | | 3.121 s +- 0.007 s | 3.129 s +- 0.012 s | 100.3% m-u | | x | 2.972 s +- 0.011 s | 2.981 s +- 0.012 s | 100.3% m-u | x | | 3.144 s +- 0.014 s | 3.141 s +- 0.011 s | 99.9% m-u | x | x | 312.2 ms +- 2.4 ms | 312.3 ms +- 2.1 ms | 100.0% l-d-r | | | 444.4 ms +- 4.3 ms | 446.9 ms +- 5.3 ms | 100.6% l-d-r | | x | 9.159 s +- 0.069 s | 9.182 s +- 0.040 s | 100.3% l-d-r | x | | 254.6 ms +- 1.6 ms | 255.2 ms +- 1.6 ms | 100.2% l-d-r | x | x | 1.525 s +- 0.007 s | 1.577 s +- 0.007 s | 103.4% <--? Differential Revision: https://phab.mercurial-scm.org/D4845
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16512
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     1
# Read the output of a "svn log --xml" command on stdin, parse it and
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     2
# print a subset of attributes common to all svn versions tested by
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     3
# hg.
28947
812eb3b7dc43 py3: use absolute_import in svnxml.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 16512
diff changeset
     4
from __future__ import absolute_import
812eb3b7dc43 py3: use absolute_import in svnxml.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 16512
diff changeset
     5
import sys
812eb3b7dc43 py3: use absolute_import in svnxml.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 16512
diff changeset
     6
import xml.dom.minidom
16512
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     7
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     8
def xmltext(e):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
     9
    return ''.join(c.data for c
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    10
                   in e.childNodes
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    11
                   if c.nodeType == c.TEXT_NODE)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    12
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    13
def parseentry(entry):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    14
    e = {}
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    15
    e['revision'] = entry.getAttribute('revision')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    16
    e['author'] = xmltext(entry.getElementsByTagName('author')[0])
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    17
    e['msg'] = xmltext(entry.getElementsByTagName('msg')[0])
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    18
    e['paths'] = []
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    19
    paths = entry.getElementsByTagName('paths')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    20
    if paths:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    21
        paths = paths[0]
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    22
        for p in paths.getElementsByTagName('path'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    23
            action = p.getAttribute('action')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    24
            path = xmltext(p)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    25
            frompath = p.getAttribute('copyfrom-path')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    26
            fromrev = p.getAttribute('copyfrom-rev')
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    27
            e['paths'].append((path, action, frompath, fromrev))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    28
    return e
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    29
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    30
def parselog(data):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    31
    entries = []
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    32
    doc = xml.dom.minidom.parseString(data)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    33
    for e in doc.getElementsByTagName('logentry'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    34
        entries.append(parseentry(e))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    35
    return entries
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    36
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    37
def printentries(entries):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    38
    fp = sys.stdout
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    39
    for e in entries:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    40
        for k in ('revision', 'author', 'msg'):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    41
            fp.write(('%s: %s\n' % (k, e[k])).encode('utf-8'))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    42
        for path, action, fpath, frev in sorted(e['paths']):
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    43
            frominfo = ''
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    44
            if frev:
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    45
                frominfo = ' (from %s@%s)' % (fpath, frev)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    46
            p = ' %s %s%s\n' % (action, path, frominfo)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    47
            fp.write(p.encode('utf-8'))
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    48
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    49
if __name__ == '__main__':
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    50
    data = sys.stdin.read()
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    51
    entries = parselog(data)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    52
    printentries(entries)
c58bdecdb800 test-convert-svn-sink: add helper to smooth svn xml output
Patrick Mezard <patrick@mezard.eu>
parents:
diff changeset
    53