Skip to content

Instantly share code, notes, and snippets.

@KeyWeeUsr
Forked from osdf/test_numpy.py
Created June 21, 2016 10:34
Show Gist options
  • Save KeyWeeUsr/2278549007fb44c1496ed4d133b7d366 to your computer and use it in GitHub Desktop.
Save KeyWeeUsr/2278549007fb44c1496ed4d133b7d366 to your computer and use it in GitHub Desktop.
Testing numpy and scipy setups
#!/usr/bin/env python
import numpy
import sys
import timeit
try:
import numpy.core._dotblas
print 'FAST BLAS'
except ImportError:
print 'slow blas'
print "version:", numpy.__version__
print "maxint:", sys.maxint
print
x = numpy.random.random((1000,1000))
setup = "import numpy; x = numpy.random.random((1000,1000))"
count = 5
t = timeit.Timer("numpy.dot(x, x.T)", setup=setup)
print "dot:", t.timeit(count)/count, "sec"
#!/usr/bin/env python
import timeit
setup = "import numpy;\
import scipy.linalg as linalg;\
x = numpy.random.random((1000,1000));\
z = numpy.dot(x, x.T)"
count = 5
t = timeit.Timer("linalg.cholesky(z, lower=True)", setup=setup)
print "cholesky:", t.timeit(count)/count, "sec"
t = timeit.Timer("linalg.svd(z)", setup=setup)
print "svd:", t.timeit(count)/count, "sec"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment