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