[pypy-commit] pypy improve-rbigint: Some more tweaks + rshift and lshift benchmark
stian
noreply at buildbot.pypy.org
Sat Jul 21 18:41:26 CEST 2012
Author: stian
Branch: improve-rbigint
Changeset: r56338:713dc82e5b4a
Date: 2012-06-26 06:52 +0200
http://bitbucket.org/pypy/pypy/changeset/713dc82e5b4a/
Log: Some more tweaks + rshift and lshift benchmark
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -420,7 +420,7 @@
if other.sign == 0:
return self
if self.sign == 0:
- return rbigint(other._digits[:], -other.sign)
+ return rbigint(other._digits, -other.sign)
if self.sign == other.sign:
result = _x_sub(self, other)
else:
@@ -447,7 +447,7 @@
if digit == 0:
return rbigint()
elif digit == 1:
- return rbigint(b._digits[:], a.sign * b.sign)
+ return rbigint(b._digits, a.sign * b.sign)
elif bsize == 1:
result = rbigint([NULLDIGIT] * 2, a.sign * b.sign)
carry = b.widedigit(0) * digit
@@ -737,10 +737,11 @@
z = rbigint([NULLDIGIT] * newsize, self.sign)
i = 0
j = wordshift
+ newdigit = UDIGIT_TYPE(0)
while i < newsize:
newdigit = (self.digit(j) >> loshift) & lomask
if i+1 < newsize:
- newdigit |= intmask(self.digit(j+1) << hishift) & himask
+ newdigit |= UDIGIT_MASK(self.digit(j+1) << hishift) & himask
z.setdigit(i, newdigit)
i += 1
j += 1
diff --git a/pypy/translator/goal/targetbigintbenchmark.py b/pypy/translator/goal/targetbigintbenchmark.py
--- a/pypy/translator/goal/targetbigintbenchmark.py
+++ b/pypy/translator/goal/targetbigintbenchmark.py
@@ -23,6 +23,8 @@
6.647562
Pypy with improvements:
+ 2.522946
+ 4.600970
2.126048
4.276203
9.662745
@@ -39,6 +41,22 @@
"""
t = time()
+ num = rbigint.fromint(1000000000)
+ for n in xrange(160000000):
+ rbigint.rshift(num, 16)
+
+
+ print time() - t
+
+ t = time()
+ num = rbigint.fromint(1000000000)
+ for n in xrange(160000000):
+ rbigint.lshift(num, 4)
+
+
+ print time() - t
+
+ t = time()
num = rbigint.fromint(100000000)
for n in xrange(80000000):
rbigint.floordiv(num, rbigint.fromint(2))
More information about the pypy-commit
mailing list