Skip to content

Commit

Permalink
timing
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Oct 1, 2014
1 parent f56728f commit 15c3e37
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 18 deletions.
18 changes: 18 additions & 0 deletions smop/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
FLAGS=

timer_so: a.so
rm -f a.py a.pyc
python go.py

timer_py: a.py
python go.py

clean:
rm -f a.* *.pyc

a.so: a.c
gcc -I /usr/include/python2.7 -L /usr/lib/python2.7 -O2 -shared -o a.so a.c

a.py: solver.m r8_random.m
python main.py $^

a.c: a.py runtime.py
cython a.py
check:
python runtime.py $(FLAGS)
python test_runtime.py $(FLAGS)
Expand Down
2 changes: 1 addition & 1 deletion smop/go.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
mv = solver(ai,af,0);
toc

disp(mv);
%disp(mv);
35 changes: 20 additions & 15 deletions smop/go.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import numpy
import numpy,time
import a
from runtime import *

ai = matlabarray(zeros_(10,10,dtype=int))
af = copy_(ai)
def main():
ai = matlabarray(zeros_(10,10,dtype=int))
af = copy_(ai)

ai[1,1]=2
ai[2,2]=3
ai[3,3]=4
ai[4,4]=5
ai[5,5]=1
ai[1,1]=2
ai[2,2]=3
ai[3,3]=4
ai[4,4]=5
ai[5,5]=1

af[9,9]=1
af[8,8]=2
af[7,7]=3
af[6,6]=4
af[10,10]=5
af[9,9]=1
af[8,8]=2
af[7,7]=3
af[6,6]=4
af[10,10]=5

mv = a.solver_(ai,af,0)
print mv
t0 = time.clock()
mv = a.solver_(ai,af,0)
t1 = time.clock()
print t1-t0
if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions smop/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,12 @@ def strread_(s, format="", nargout=1):
if format == "":
a = [float(x) for x in s.split()]
return tuple(a) if nargout > 1 else np.asanyarray([a])
raise ErrorNotImplemented
raise NotImplementedError

def strrep_(a,b,c):
if isinstance(a,str):
return a.replace(b,c)
raise ErrorNotImplemented # cell arrays
raise NotImplementedError # cell arrays

def sum_(a, dim=None):
if dim is None:
Expand Down

0 comments on commit 15c3e37

Please sign in to comment.