Show More
@@ -68,10 +68,12 b' try:' | |||||
68 | from mercurial import pycompat |
|
68 | from mercurial import pycompat | |
69 | getargspec = pycompat.getargspec # added to module after 4.5 |
|
69 | getargspec = pycompat.getargspec # added to module after 4.5 | |
70 | _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) |
|
70 | _sysstr = pycompat.sysstr # since 4.0 (or 2219f4f82ede) | |
|
71 | _xrange = pycompat.xrange # since 4.8 (or 7eba8f83129b) | |||
71 | except (ImportError, AttributeError): |
|
72 | except (ImportError, AttributeError): | |
72 | import inspect |
|
73 | import inspect | |
73 | getargspec = inspect.getargspec |
|
74 | getargspec = inspect.getargspec | |
74 | _sysstr = lambda x: x # no py3 support |
|
75 | _sysstr = lambda x: x # no py3 support | |
|
76 | _xrange = xrange | |||
75 |
|
77 | |||
76 | try: |
|
78 | try: | |
77 | # 4.7+ |
|
79 | # 4.7+ | |
@@ -931,7 +933,7 b' def perfparents(ui, repo, **opts):' | |||||
931 | if len(repo.changelog) < count: |
|
933 | if len(repo.changelog) < count: | |
932 | raise error.Abort(b"repo needs %d commits for this test" % count) |
|
934 | raise error.Abort(b"repo needs %d commits for this test" % count) | |
933 | repo = repo.unfiltered() |
|
935 | repo = repo.unfiltered() | |
934 | nl = [repo.changelog.node(i) for i in xrange(count)] |
|
936 | nl = [repo.changelog.node(i) for i in _xrange(count)] | |
935 | def d(): |
|
937 | def d(): | |
936 | for n in nl: |
|
938 | for n in nl: | |
937 | repo.changelog.parents(n) |
|
939 | repo.changelog.parents(n) | |
@@ -978,7 +980,7 b' def perflinelogedits(ui, **opts):' | |||||
978 | randint = random.randint |
|
980 | randint = random.randint | |
979 | currentlines = 0 |
|
981 | currentlines = 0 | |
980 | arglist = [] |
|
982 | arglist = [] | |
981 | for rev in xrange(edits): |
|
983 | for rev in _xrange(edits): | |
982 | a1 = randint(0, currentlines) |
|
984 | a1 = randint(0, currentlines) | |
983 | a2 = randint(a1, min(currentlines, a1 + maxhunklines)) |
|
985 | a2 = randint(a1, min(currentlines, a1 + maxhunklines)) | |
984 | b1 = randint(0, maxb1) |
|
986 | b1 = randint(0, maxb1) | |
@@ -1216,18 +1218,18 b' def perfbdiff(ui, repo, file_, rev=None,' | |||||
1216 | mdiff.textdiff(*pair) |
|
1218 | mdiff.textdiff(*pair) | |
1217 | else: |
|
1219 | else: | |
1218 | q = queue() |
|
1220 | q = queue() | |
1219 | for i in xrange(threads): |
|
1221 | for i in _xrange(threads): | |
1220 | q.put(None) |
|
1222 | q.put(None) | |
1221 | ready = threading.Condition() |
|
1223 | ready = threading.Condition() | |
1222 | done = threading.Event() |
|
1224 | done = threading.Event() | |
1223 | for i in xrange(threads): |
|
1225 | for i in _xrange(threads): | |
1224 | threading.Thread(target=_bdiffworker, |
|
1226 | threading.Thread(target=_bdiffworker, | |
1225 | args=(q, blocks, xdiff, ready, done)).start() |
|
1227 | args=(q, blocks, xdiff, ready, done)).start() | |
1226 | q.join() |
|
1228 | q.join() | |
1227 | def d(): |
|
1229 | def d(): | |
1228 | for pair in textpairs: |
|
1230 | for pair in textpairs: | |
1229 | q.put(pair) |
|
1231 | q.put(pair) | |
1230 | for i in xrange(threads): |
|
1232 | for i in _xrange(threads): | |
1231 | q.put(None) |
|
1233 | q.put(None) | |
1232 | with ready: |
|
1234 | with ready: | |
1233 | ready.notify_all() |
|
1235 | ready.notify_all() | |
@@ -1238,7 +1240,7 b' def perfbdiff(ui, repo, file_, rev=None,' | |||||
1238 |
|
1240 | |||
1239 | if withthreads: |
|
1241 | if withthreads: | |
1240 | done.set() |
|
1242 | done.set() | |
1241 | for i in xrange(threads): |
|
1243 | for i in _xrange(threads): | |
1242 | q.put(None) |
|
1244 | q.put(None) | |
1243 | with ready: |
|
1245 | with ready: | |
1244 | ready.notify_all() |
|
1246 | ready.notify_all() | |
@@ -1472,7 +1474,7 b' def perfrevlogrevisions(ui, repo, file_=' | |||||
1472 | beginrev, endrev = endrev, beginrev |
|
1474 | beginrev, endrev = endrev, beginrev | |
1473 | dist = -1 * dist |
|
1475 | dist = -1 * dist | |
1474 |
|
1476 | |||
1475 | for x in xrange(beginrev, endrev, dist): |
|
1477 | for x in _xrange(beginrev, endrev, dist): | |
1476 | # Old revisions don't support passing int. |
|
1478 | # Old revisions don't support passing int. | |
1477 | n = rl.node(x) |
|
1479 | n = rl.node(x) | |
1478 | rl.revision(n) |
|
1480 | rl.revision(n) | |
@@ -1885,19 +1887,19 b' def perfloadmarkers(ui, repo):' | |||||
1885 | def perflrucache(ui, mincost=0, maxcost=100, costlimit=0, size=4, |
|
1887 | def perflrucache(ui, mincost=0, maxcost=100, costlimit=0, size=4, | |
1886 | gets=10000, sets=10000, mixed=10000, mixedgetfreq=50, **opts): |
|
1888 | gets=10000, sets=10000, mixed=10000, mixedgetfreq=50, **opts): | |
1887 | def doinit(): |
|
1889 | def doinit(): | |
1888 | for i in xrange(10000): |
|
1890 | for i in _xrange(10000): | |
1889 | util.lrucachedict(size) |
|
1891 | util.lrucachedict(size) | |
1890 |
|
1892 | |||
1891 | costrange = list(range(mincost, maxcost + 1)) |
|
1893 | costrange = list(range(mincost, maxcost + 1)) | |
1892 |
|
1894 | |||
1893 | values = [] |
|
1895 | values = [] | |
1894 | for i in xrange(size): |
|
1896 | for i in _xrange(size): | |
1895 | values.append(random.randint(0, sys.maxint)) |
|
1897 | values.append(random.randint(0, sys.maxint)) | |
1896 |
|
1898 | |||
1897 | # Get mode fills the cache and tests raw lookup performance with no |
|
1899 | # Get mode fills the cache and tests raw lookup performance with no | |
1898 | # eviction. |
|
1900 | # eviction. | |
1899 | getseq = [] |
|
1901 | getseq = [] | |
1900 | for i in xrange(gets): |
|
1902 | for i in _xrange(gets): | |
1901 | getseq.append(random.choice(values)) |
|
1903 | getseq.append(random.choice(values)) | |
1902 |
|
1904 | |||
1903 | def dogets(): |
|
1905 | def dogets(): | |
@@ -1922,7 +1924,7 b' def perflrucache(ui, mincost=0, maxcost=' | |||||
1922 | # Set mode tests insertion speed with cache eviction. |
|
1924 | # Set mode tests insertion speed with cache eviction. | |
1923 | setseq = [] |
|
1925 | setseq = [] | |
1924 | costs = [] |
|
1926 | costs = [] | |
1925 | for i in xrange(sets): |
|
1927 | for i in _xrange(sets): | |
1926 | setseq.append(random.randint(0, sys.maxint)) |
|
1928 | setseq.append(random.randint(0, sys.maxint)) | |
1927 | costs.append(random.choice(costrange)) |
|
1929 | costs.append(random.choice(costrange)) | |
1928 |
|
1930 | |||
@@ -1943,7 +1945,7 b' def perflrucache(ui, mincost=0, maxcost=' | |||||
1943 |
|
1945 | |||
1944 | # Mixed mode randomly performs gets and sets with eviction. |
|
1946 | # Mixed mode randomly performs gets and sets with eviction. | |
1945 | mixedops = [] |
|
1947 | mixedops = [] | |
1946 | for i in xrange(mixed): |
|
1948 | for i in _xrange(mixed): | |
1947 | r = random.randint(0, 100) |
|
1949 | r = random.randint(0, 100) | |
1948 | if r < mixedgetfreq: |
|
1950 | if r < mixedgetfreq: | |
1949 | op = 0 |
|
1951 | op = 0 |
General Comments 0
You need to be logged in to leave comments.
Login now