In [1]:
pwd


Out[1]:
u'/Users/rjl/git/bitbucket/uwhpsc/lectures/lecture6'

In [2]:
import mysqrt

In [3]:
mysqrt.test()


Testing with x = 0.000000000000000e+00
  s = 0.000000000000000e+00,  numpy.sqrt = 0.000000000000000e+00
Testing with x = 2.000000000000000e+00
  s = 1.414213562373095e+00,  numpy.sqrt = 1.414213562373095e+00
Testing with x = 1.000000000000000e+02
  s = 1.000000000000000e+01,  numpy.sqrt = 1.000000000000000e+01
Testing with x = 1.000000000000000e+04
  s = 1.000000000000000e+02,  numpy.sqrt = 1.000000000000000e+02
Testing with x = 1.000000000000000e-04
  s = 1.000000000000000e-02,  numpy.sqrt = 1.000000000000000e-02

In [4]:
run mysqrt.py


Running test... 
Testing with x = 0.000000000000000e+00
  s = 0.000000000000000e+00,  numpy.sqrt = 0.000000000000000e+00
Testing with x = 2.000000000000000e+00
  s = 1.414213562373095e+00,  numpy.sqrt = 1.414213562373095e+00
Testing with x = 1.000000000000000e+02
  s = 1.000000000000000e+01,  numpy.sqrt = 1.000000000000000e+01
Testing with x = 1.000000000000000e+04
  s = 1.000000000000000e+02,  numpy.sqrt = 1.000000000000000e+02
Testing with x = 1.000000000000000e-04
  s = 1.000000000000000e-02,  numpy.sqrt = 1.000000000000000e-02

In [5]:
mysqrt.__name__


Out[5]:
'mysqrt'

In [6]:
time sqrt(2.)


CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.00 s
Out[6]:
1.4142135623730951

In [7]:
timeit sqrt(2.)


100000 loops, best of 3: 2.01 us per loop

us means micro-seconds, 1e-6 second


In [9]:
timeit mysqrt.sqrt2(2.)


100000 loops, best of 3: 5.94 us per loop

In [10]:
timeit y = sqrt(linspace(0,1,1000))


10000 loops, best of 3: 20.5 us per loop

In [11]:
%%timeit
y = zeros(1000)
for i in range(1000):
    y[i] = sqrt(i)


100 loops, best of 3: 3.02 ms per loop

ms = millisecond = 1e-3 second = 1000 micro seconds


In [ ]: