/[escript]/trunk/escript/test/python/TimingTests.py
ViewVC logotype

Annotation of /trunk/escript/test/python/TimingTests.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (hide annotations)
Tue Aug 23 01:24:31 2005 UTC (14 years, 3 months ago) by jgs
Original Path: trunk/esys2/escript/test/python/TimingTests.py
File MIME type: text/x-python
File size: 5254 byte(s)
Merge of development branch dev-02 back to main trunk on 2005-08-23

1 jgs 148 import sys
2     import unittest
3     import os
4    
5     import time
6    
7     from escript.escript import *
8     from finley import finley
9    
10     import numarray
11     from numarray import array,Float64,ones,greater
12    
13     """
14     Miscellaneous escript/Data timing tests.
15    
16     Version $Id$
17     """
18    
19     arglist = [ \
20     3.0, \
21     [3,4], \
22     [[1,2],[3,4]], \
23     [[15,8],[12,8]], \
24     [[[15,8],[12,8]],[[-9,9],[13,8]]] \
25     ]
26    
27     def turnToArray(val):
28     out=array(val,Float64)
29     return out
30    
31     def prepareArg(val,ex,wh):
32     if ex=="Expanded":
33     exx=True
34     else:
35     exx=False
36     out=Data(val,what=wh,expand=exx)
37     return out
38    
39     def checkResult(text,res,val0,val1,val2,wh):
40     ref=Data(val0,what=wh,expand=False)
41     ref.setTaggedValue(Tag1,val1)
42     ref.setTaggedValue(Tag2,val2)
43     norm=Lsup(ref)+tol
44     error=Lsup(ref-res)/norm
45     print "@@ %s, shape %s: error = %e"%(text,ref.getShape(),error)
46     if error>tol:
47     #raise SystemError,"@@ %s at %s: error is too large"%(text,wh)
48     print "**** %s : error is too large"%(text)
49    
50     def getRank(arg):
51     if isinstance(arg,Data):
52     return arg.getRank()
53     else:
54     g=array(arg)
55     if g.rank==0:
56     return 1
57     else:
58     return g.rank
59    
60     def isScalar(arg):
61     if isinstance(arg,Data):
62     if arg.getRank()==1 and arg.getShape()[0]==1:
63     return not None
64     else:
65     return None
66     else:
67     g=array(arg)
68     if g.rank==0:
69     return not None
70     else:
71     if g.rank==1 and g.shape[0]==1:
72     return not None
73     else:
74     return None
75    
76     #
77     # ==============================================================
78    
79     print "\n\n"
80    
81     msh=finley.Rectangle(1000,1000,1)
82    
83     for wh in [Function(msh)]:
84    
85     print wh
86    
87     for ex in ["Expanded"]:
88    
89     for a in arglist:
90    
91     print "\n", ex, a, "==>"
92    
93     arg=prepareArg(a,ex,wh)
94    
95     starttime = time.clock()
96    
97     print "\nabs:",
98     arg_abs = arg.abs()
99    
100     stoptime = time.clock()
101     elapsed = stoptime - starttime
102     starttime = time.clock()
103     print elapsed
104    
105     print "\nmaxval:",
106     arg_maxval = arg.maxval()
107    
108     stoptime = time.clock()
109     elapsed = stoptime - starttime
110     starttime = time.clock()
111     print elapsed
112    
113     print "\nminval:",
114     arg_minval = arg.minval()
115    
116     stoptime = time.clock()
117     elapsed = stoptime - starttime
118     starttime = time.clock()
119     print elapsed
120    
121     print "\nmindp:",
122     arg_mindp = arg.mindp()
123    
124     stoptime = time.clock()
125     elapsed = stoptime - starttime
126     starttime = time.clock()
127     print elapsed
128    
129     print "\nlength",
130     arg_length = arg.length()
131    
132     stoptime = time.clock()
133     elapsed = stoptime - starttime
134     starttime = time.clock()
135     print elapsed
136    
137     print "\ntrace",
138     arg_trace = arg.trace()
139    
140     stoptime = time.clock()
141     elapsed = stoptime - starttime
142     starttime = time.clock()
143     print elapsed
144    
145     print "\nsign",
146     arg_sin = arg.sign()
147    
148     stoptime = time.clock()
149     elapsed = stoptime - starttime
150     starttime = time.clock()
151     print elapsed
152    
153     print "\nexp",
154     arg_exp = arg.exp()
155    
156     stoptime = time.clock()
157     elapsed = stoptime - starttime
158     starttime = time.clock()
159     print elapsed
160    
161     print "\nsqrt",
162     arg_sqrt = arg.sqrt()
163    
164     stoptime = time.clock()
165     elapsed = stoptime - starttime
166     starttime = time.clock()
167     print elapsed
168    
169     print "\nneg",
170     arg_neg = arg.neg()
171    
172     stoptime = time.clock()
173     elapsed = stoptime - starttime
174     starttime = time.clock()
175     print elapsed
176    
177     print "\npos",
178     arg_pos = arg.pos()
179    
180     stoptime = time.clock()
181     elapsed = stoptime - starttime
182     starttime = time.clock()
183     print elapsed
184    
185     print "\nsin",
186     arg_sin = arg.sin()
187    
188     stoptime = time.clock()
189     elapsed = stoptime - starttime
190     starttime = time.clock()
191     print elapsed
192    
193     print "\ncos",
194     arg_cos = arg.cos()
195    
196     stoptime = time.clock()
197     elapsed = stoptime - starttime
198     starttime = time.clock()
199     print elapsed
200    
201     print "\ntan",
202     arg_tab = arg.tan()
203    
204     stoptime = time.clock()
205     elapsed = stoptime - starttime
206     starttime = time.clock()
207     print elapsed
208    
209     print "\nlog",
210     arg_log = arg.log()
211    
212     stoptime = time.clock()
213     elapsed = stoptime - starttime
214     starttime = time.clock()
215     print elapsed
216    
217     print "\nln",
218     arg_ln = arg.ln()
219    
220     stoptime = time.clock()
221     elapsed = stoptime - starttime
222     starttime = time.clock()
223     print elapsed
224    
225     print "\nLsup",
226     arg_Lsup = arg.Lsup()
227    
228     stoptime = time.clock()
229     elapsed = stoptime - starttime
230     starttime = time.clock()
231     print elapsed
232    
233     print "\nLinf",
234     arg_Linf = arg.Linf()
235    
236     stoptime = time.clock()
237     elapsed = stoptime - starttime
238     starttime = time.clock()
239     print elapsed
240    
241     print "\nsup",
242     arg_sup = arg.sup()
243    
244     stoptime = time.clock()
245     elapsed = stoptime - starttime
246     starttime = time.clock()
247     print elapsed
248    
249     print "\ninf",
250     arg_inf = arg.inf()
251    
252     stoptime = time.clock()
253     elapsed = stoptime - starttime
254     starttime = time.clock()
255     print elapsed
256    
257     sys.exit(0)
258     # end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26