PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/test2/timing3.py

http://gmpy.googlecode.com/
Python | 27 lines | 26 code | 1 blank | 0 comment | 1 complexity | b9d4f9908f894107f83f92e2a0187f76 MD5 | raw file
 1import gmpy2 as _g
 2import time
 3
 4print "Typical expected results would be:","""
 5D:\PySym>python timing.py
 6Factorial of 10000 took 0.0619989238859 (35660 digits)
 7Fibonacci of 10000 took 0.000744228458022 (2090 digits)
 8Factorial of 100000 took 4.44311764676 (456574 digits)
 9Fibonacci of 100000 took 0.022344453738 (20899 digits)
10Factorial of 1000000 took 152.151135367 (5565709 digits)
11Fibonacci of 1000000 took 0.670207059778 (208988 digits)
12"""
13
14print "Actual timings and results...:"
15for i in (10000,100000,1000000):
16    start=time.clock()
17    x=_g.fac(i)
18    stend=time.clock()
19    print "Factorial of %d took %s (%d digits)" % (
20        i, stend-start, x.num_digits())
21
22    start=time.clock()
23    x=_g.fib(i)
24    stend=time.clock()
25    print "Fibonacci of %d took %s (%d digits)" % (
26        i, stend-start, x.num_digits())
27