changeset 39823:c4ab9fa81377

py3: work around the lack of sys.maxint in contrib/perf
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 21 Sep 2018 20:16:13 -0400
parents 86dbeb7c9a11
children db875f97a969
files contrib/perf.py
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Fri Sep 21 20:13:14 2018 -0400
+++ b/contrib/perf.py	Fri Sep 21 20:16:13 2018 -0400
@@ -69,9 +69,14 @@
     getargspec = pycompat.getargspec  # added to module after 4.5
     _sysstr = pycompat.sysstr         # since 4.0 (or 2219f4f82ede)
     _xrange = pycompat.xrange         # since 4.8 (or 7eba8f83129b)
+    if pycompat.ispy3:
+        _maxint = sys.maxsize  # per py3 docs for replacing maxint
+    else:
+        _maxint = sys.maxint
 except (ImportError, AttributeError):
     import inspect
     getargspec = inspect.getargspec
+    _maxint = sys.maxint              # no py3 support
     _sysstr = lambda x: x             # no py3 support
     _xrange = xrange
 
@@ -1894,7 +1899,7 @@
 
     values = []
     for i in _xrange(size):
-        values.append(random.randint(0, sys.maxint))
+        values.append(random.randint(0, _maxint))
 
     # Get mode fills the cache and tests raw lookup performance with no
     # eviction.
@@ -1925,7 +1930,7 @@
     setseq = []
     costs = []
     for i in _xrange(sets):
-        setseq.append(random.randint(0, sys.maxint))
+        setseq.append(random.randint(0, _maxint))
         costs.append(random.choice(costrange))
 
     def doinserts():