gmpy 1.01 rc near... anybody wanna test>

M

mensanator

What processor are you running?

Drat, didn't see this before I left work. I'm fairly certain it was a
Pentium 4, definitely 1.7GHz, Win2000 and Python 2.3.

So I thought I would run the test again on my home computers,
a Pentium 4 1.5 GHz WinXP Python 2.3 and a laptop with a
Celeron 2.8 GHz WinXP Python 2.4.

Here are the Celeron/Python2.4 numbers (and original test times)

BF: 27.89 sec gen6 (31.92)
CF: 0.203 sec gen9 (0.234)
V: 5.062 sec gen9 (8.766)
 
M

mensanator

Drat, didn't see this before I left work. I'm fairly certain it was a
Pentium 4, definitely 1.7GHz, Win2000 and Python 2.3.

So I thought I would run the test again on my home computers,
a Pentium 4 1.5 GHz WinXP Python 2.3 and a laptop with a
Celeron 2.8 GHz WinXP Python 2.4.

Here are the Celeron/Python2.4 numbers (and original test times)

BF: 27.89 sec gen6 (31.92)
CF: 0.203 sec gen9 (0.234)
V: 5.062 sec gen9 (8.766)

Oops, accidentally hit the send button. I didn't give you the
results from my home desktop machine. And those are
interesting.

I did not intend for this test to be a benchmark, simply to
make sure gmpy (and my library of Collatz Functions) were
working properly. Can you imagine my shock at the reults
of the closed form test:

gmpy.version: 1.01

Closed form: Type12MH(k,i)
Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

2**(6*((i-1)*9**(k-1)+(9**(k-1)-1)/2+1)-1)-1

2**5-1 generation: 1 0 seconds
2**29-1 generation: 2 0 seconds
2**245-1 generation: 3 0.015 seconds
2**2189-1 generation: 4 0 seconds
2**19685-1 generation: 5 0 seconds
2**177149-1 generation: 6 0.219 seconds
2**1594325-1 generation: 7 29.22 seconds
2**14348909-1 generation: 8 5295 seconds

That's 88 minutes for the gen8 test alone (gen9 is still running).
I was expecting a quarter second for the entire test! I realize that
my office pc and my home pc are configured differently but there
shouldn't be that much difference with the same version of Python
and gmpy.

At first I thought it was locking up, but it didn't have the symptoms
of a lockup: menus still worked, Task manager didn't report not
responding, and sure enough, it completed gen7 eventually.

I finally figured it out, though. I had been toying with my Collatz
Functions and made what I thought was a trivial change:

Original function
def Type12MH(k,i):
"""Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

Type12MH(k,i)
k: generation
i: member of generation
returns Hailstone (a)
"""
if (k<1) or (i<1): return 0
a = (i-1)*9**(k-1) + (9**(k-1) - 1)/2 + 1
return 2**(6*a - 1) - 1

Now I know better than to allow coersion to mpz's to take place
inside a loop, but this function doesn't loop. Nevertheless, I changed
it to

def Type12MH(k,i):
"""Find ith, kth Generation Type [1,2] Mersenne Hailstone
using the closed form equation

Type12MH(k,i)
k: generation
i: member of generation
returns Hailstone (a)
"""
ONE = gmpy.mpz(1)
TWO = gmpy.mpz(2)
SIX = gmpy.mpz(6)
NIN = gmpy.mpz(9)

if (k<1) or (i<1): return 0

i = gmpy.mpz(i)
k = gmpy.mpz(k)

# a = (i-1)*9**(k-1) + (9**(k-1) - 1)/2 + 1
# return 2**(6*a - 1) - 1

a = (i-ONE)*NIN**(k-ONE) + (NIN**(k-ONE) - ONE)/TWO + ONE
return TWO**(SIX*a - ONE) - ONE

And this was what is making my home desktop run so slow
(at least with mega-bit sized numbers). As soon as I updated the
Collatz Library, I got normal reults:

BF: 37.11 sec gen6
CF: 0.563 sec gen9
V: 1.093 sec gen9

(Verified by setting it back to original.)

Wow. Didn't realize things were that sensitive. Looks like I'll
have to review a lot of my programs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,351
Members
48,036
Latest member
nickwillsonn

Latest Threads

Top