#!/usr/bin/env python # Originally written by Simon Burton. Fixes by Todd Miller import sys from time import time def test_add_Numeric(count=100): import Numeric as N import scipy import RandomArray as RA a = RA.uniform( -1, 1, shape=(1000,1000) ) b = RA.uniform( -1, 1, shape=(1000,1000) ) t0 = time() for i in range(count): c = a + b t = time() - t0 t /= count print "Numeric + :",t def test_add_numarray(count=100): import numarray as na import numarray.random_array as ra a = ra.uniform( -1, 1, shape=(1000,1000) ) b = ra.uniform( -1, 1, shape=(1000,1000) ) t0 = time() for i in range(count): c = a + b t = time() - t0 t /= count print "numarray + :",t def test_matrixmul_Numeric(count=10): import Numeric as N import scipy import RandomArray as RA a = RA.uniform( -1, 1, shape=(1000,1000) ) b = RA.uniform( -1, 1, shape=(1000,1000) ) t0 = time() for i in range(count): c = N.matrixmultiply( a, b ) t = time() - t0 t /= count print "Numeric matrixmultiply :",t def test_matrixmul_numarray(count=10): import numarray as na import numarray.random_array as ra a = ra.uniform( -1, 1, shape=(1000,1000) ) b = ra.uniform( -1, 1, shape=(1000,1000) ) t0 = time() for i in range(count): c = na.matrixmultiply( a, b ) t = time() - t0 t /= count print "numarray matrixmultiply :",t def test_eig_Numeric(count=10): import Numeric as N import scipy import RandomArray as RA import LinearAlgebra as LA a = RA.uniform( -1, 1, shape=(500,500) ) t0 = time() for i in range(count): c = LA.eigenvalues( a ) t = time() - t0 t /= count print "Numeric eigenvalues :",t def test_eig_numarray(count=10): import numarray as na import numarray.random_array as ra import numarray.linear_algebra as la a = ra.uniform( -1, 1, shape=(500,500) ) t0 = time() for i in range(count): c = la.eigenvalues( a ) t = time() - t0 t /= count print "numarray eigenvalues :",t test_add_numarray() test_matrixmul_numarray() test_eig_numarray() print test_add_Numeric() test_matrixmul_Numeric() test_eig_Numeric()