diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2008-08-23 23:55:01 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2008-08-23 23:55:01 +0000 |
commit | 46facee53a506cd26c00ad12d482a682b0176404 (patch) | |
tree | 563e932b1888e28c19a0ca6cc0f6e02bfe0b6f3f /doc/numpybook/comparison/timing.py | |
parent | d14243ca1fa3373babfd5b699e12dff177f60dba (diff) | |
download | numpy-46facee53a506cd26c00ad12d482a682b0176404.tar.gz |
Move book to docs directory.
Diffstat (limited to 'doc/numpybook/comparison/timing.py')
-rw-r--r-- | doc/numpybook/comparison/timing.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/doc/numpybook/comparison/timing.py b/doc/numpybook/comparison/timing.py new file mode 100644 index 000000000..14841d7cb --- /dev/null +++ b/doc/numpybook/comparison/timing.py @@ -0,0 +1,63 @@ + +import timeit + +pyrex_pre = """ +import numpy as N +a = N.random.rand(%d,%d) +import filter +""" + +pyrex_run = """ +b = filter.filter(a) +""" + +weave_pre = """ +import numpy as N +a = N.random.rand(%d,%d) +import filter +""" + +weave_run = """ +b = filter.filter(a) +""" + +ctypes_pre = """ +import numpy as N +a = N.random.rand(%d,%d) +import filter +""" + +ctypes_run = """ +b = filter.filter(a) +""" + +f2py_pre = """ +import numpy as N +a = N.random.rand(%d, %d).T +import filter +""" + +f2py_run = """ +b = N.zeros_like(a) +filter.DFILTER2D(a,b) +""" + +N = [10,20,30,40,50,100,200,300, 400, 500] + +res = {} + +import os +import sys +path = sys.path + +for kind in ['f2py']:#['ctypes', 'pyrex', 'weave', 'f2py']: + res[kind] = [] + sys.path = ['/Users/oliphant/numpybook/%s' % (kind,)] + path + print sys.path + for n in N: + print "%s - %d" % (kind, n) + t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n))) + mytime = min(t.repeat(3,100)) + res[kind].append(mytime) + + |