[PATCH 4 of 8] py3: switch contrib/perf from xrange to pycompat.xrange

Matt Harbison mharbison72 at gmail.com
Sat Sep 22 11:28:40 EDT 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1537575194 14400
#      Fri Sep 21 20:13:14 2018 -0400
# Node ID 04f33f6d0d4ab3006dd83b26c70a61ceee66a720
# Parent  c0c842de276702455060c3d5fd3a6aa80185cdc6
py3: switch contrib/perf from xrange to pycompat.xrange

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -927,7 +927,7 @@ def perfparents(ui, repo, **opts):
     if len(repo.changelog) < count:
         raise error.Abort(b"repo needs %d commits for this test" % count)
     repo = repo.unfiltered()
-    nl = [repo.changelog.node(i) for i in xrange(count)]
+    nl = [repo.changelog.node(i) for i in pycompat.xrange(count)]
     def d():
         for n in nl:
             repo.changelog.parents(n)
@@ -974,7 +974,7 @@ def perflinelogedits(ui, **opts):
     randint = random.randint
     currentlines = 0
     arglist = []
-    for rev in xrange(edits):
+    for rev in pycompat.xrange(edits):
         a1 = randint(0, currentlines)
         a2 = randint(a1, min(currentlines, a1 + maxhunklines))
         b1 = randint(0, maxb1)
@@ -1212,18 +1212,18 @@ def perfbdiff(ui, repo, file_, rev=None,
                     mdiff.textdiff(*pair)
     else:
         q = queue()
-        for i in xrange(threads):
+        for i in pycompat.xrange(threads):
             q.put(None)
         ready = threading.Condition()
         done = threading.Event()
-        for i in xrange(threads):
+        for i in pycompat.xrange(threads):
             threading.Thread(target=_bdiffworker,
                              args=(q, blocks, xdiff, ready, done)).start()
         q.join()
         def d():
             for pair in textpairs:
                 q.put(pair)
-            for i in xrange(threads):
+            for i in pycompat.xrange(threads):
                 q.put(None)
             with ready:
                 ready.notify_all()
@@ -1234,7 +1234,7 @@ def perfbdiff(ui, repo, file_, rev=None,
 
     if withthreads:
         done.set()
-        for i in xrange(threads):
+        for i in pycompat.xrange(threads):
             q.put(None)
         with ready:
             ready.notify_all()
@@ -1468,7 +1468,7 @@ def perfrevlogrevisions(ui, repo, file_=
             beginrev, endrev = endrev, beginrev
             dist = -1 * dist
 
-        for x in xrange(beginrev, endrev, dist):
+        for x in pycompat.xrange(beginrev, endrev, dist):
             # Old revisions don't support passing int.
             n = rl.node(x)
             rl.revision(n)
@@ -1881,19 +1881,19 @@ def perfloadmarkers(ui, repo):
 def perflrucache(ui, mincost=0, maxcost=100, costlimit=0, size=4,
                  gets=10000, sets=10000, mixed=10000, mixedgetfreq=50, **opts):
     def doinit():
-        for i in xrange(10000):
+        for i in pycompat.xrange(10000):
             util.lrucachedict(size)
 
     costrange = list(range(mincost, maxcost + 1))
 
     values = []
-    for i in xrange(size):
+    for i in pycompat.xrange(size):
         values.append(random.randint(0, sys.maxint))
 
     # Get mode fills the cache and tests raw lookup performance with no
     # eviction.
     getseq = []
-    for i in xrange(gets):
+    for i in pycompat.xrange(gets):
         getseq.append(random.choice(values))
 
     def dogets():
@@ -1918,7 +1918,7 @@ def perflrucache(ui, mincost=0, maxcost=
     # Set mode tests insertion speed with cache eviction.
     setseq = []
     costs = []
-    for i in xrange(sets):
+    for i in pycompat.xrange(sets):
         setseq.append(random.randint(0, sys.maxint))
         costs.append(random.choice(costrange))
 
@@ -1939,7 +1939,7 @@ def perflrucache(ui, mincost=0, maxcost=
 
     # Mixed mode randomly performs gets and sets with eviction.
     mixedops = []
-    for i in xrange(mixed):
+    for i in pycompat.xrange(mixed):
         r = random.randint(0, 100)
         if r < mixedgetfreq:
             op = 0


More information about the Mercurial-devel mailing list