1 |
ksteube |
1809 |
|
2 |
|
|
######################################################## |
3 |
ksteube |
1312 |
# |
4 |
ksteube |
1809 |
# Copyright (c) 2003-2008 by University of Queensland |
5 |
|
|
# Earth Systems Science Computational Center (ESSCC) |
6 |
|
|
# http://www.uq.edu.au/esscc |
7 |
ksteube |
1312 |
# |
8 |
ksteube |
1809 |
# Primary Business: Queensland, Australia |
9 |
|
|
# Licensed under the Open Software License version 3.0 |
10 |
|
|
# http://www.opensource.org/licenses/osl-3.0.php |
11 |
ksteube |
1312 |
# |
12 |
ksteube |
1809 |
######################################################## |
13 |
ksteube |
1312 |
|
14 |
ksteube |
1809 |
__copyright__="""Copyright (c) 2003-2008 by University of Queensland |
15 |
|
|
Earth Systems Science Computational Center (ESSCC) |
16 |
|
|
http://www.uq.edu.au/esscc |
17 |
|
|
Primary Business: Queensland, Australia""" |
18 |
|
|
__license__="""Licensed under the Open Software License version 3.0 |
19 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
20 |
jfenwick |
2344 |
__url__="https://launchpad.net/escript-finley" |
21 |
ksteube |
1809 |
|
22 |
jgs |
149 |
""" |
23 |
|
|
Miscellaneous escript/Data timing tests. |
24 |
|
|
""" |
25 |
|
|
|
26 |
jgs |
148 |
import sys |
27 |
|
|
import os |
28 |
|
|
import time |
29 |
|
|
|
30 |
jgs |
149 |
from esys.escript import * |
31 |
jgs |
153 |
from esys import bruce |
32 |
jgs |
148 |
|
33 |
jgs |
149 |
# |
34 |
|
|
# ================== data values to test with ========================= |
35 |
jgs |
148 |
|
36 |
|
|
arglist = [ \ |
37 |
|
|
3.0, \ |
38 |
jgs |
149 |
[3.0,4.0], \ |
39 |
|
|
[[1.0,2.0],[3.0,4.0]], \ |
40 |
jgs |
570 |
[[[15.0,8.0],[12.0,8.0]],[[-9.0,9.0],[13.0,8.0]]], \ |
41 |
|
|
[[[[14.0,7.0],[11.0,8.5]],[[-970,9.2],[18.0,8.0]]],[[[-4.4,7.0],[93.0,8.0]],[[-1.0,9.4],[12.0,9.0]]]] \ |
42 |
jgs |
148 |
] |
43 |
|
|
|
44 |
jgs |
149 |
testlist = [ |
45 |
jgs |
570 |
"_trace ", |
46 |
|
|
"_maxval ", |
47 |
|
|
"_minval ", |
48 |
|
|
"_wherePositive ", |
49 |
|
|
"_whereNegative ", |
50 |
|
|
"_whereNonNegative", |
51 |
|
|
"_whereNonPositive", |
52 |
|
|
"_whereZero ", |
53 |
|
|
"_whereNonZero ", |
54 |
|
|
"_sin ", |
55 |
|
|
"_cos ", |
56 |
|
|
"_tan ", |
57 |
|
|
"_asin ", |
58 |
|
|
"_acos ", |
59 |
|
|
"_atan ", |
60 |
|
|
"_sinh ", |
61 |
|
|
"_cosh ", |
62 |
|
|
"_tanh ", |
63 |
|
|
"_asinh ", |
64 |
|
|
"_acosh ", |
65 |
|
|
"_atanh ", |
66 |
|
|
"_exp ", |
67 |
|
|
"_sqrt ", |
68 |
|
|
"_log10 ", |
69 |
|
|
"_log ", |
70 |
|
|
"_sign ", |
71 |
|
|
"_Lsup ", |
72 |
|
|
"_sup ", |
73 |
|
|
"_inf " |
74 |
jgs |
149 |
] |
75 |
jgs |
148 |
|
76 |
jgs |
149 |
# |
77 |
|
|
# ================== method definitions ========================= |
78 |
|
|
|
79 |
jgs |
148 |
def prepareArg(val,ex,wh): |
80 |
jgs |
149 |
if ex=="Expanded": |
81 |
|
|
exx=True |
82 |
|
|
else: |
83 |
|
|
exx=False |
84 |
|
|
out=Data(val,what=wh,expand=exx) |
85 |
jgs |
570 |
if ex=="Tagged": |
86 |
|
|
out.tag() |
87 |
jgs |
149 |
return out |
88 |
jgs |
148 |
|
89 |
jgs |
149 |
def getStartTime(): |
90 |
|
|
return time.clock() |
91 |
jgs |
148 |
|
92 |
jgs |
149 |
def calcElapsedTime(starttime): |
93 |
|
|
stoptime = time.clock() |
94 |
|
|
elapsed = stoptime - starttime |
95 |
jgs |
153 |
print "\t\t", elapsed |
96 |
jgs |
148 |
|
97 |
jgs |
149 |
def runTest(arg,test): |
98 |
jgs |
153 |
print "\t\t", test, |
99 |
jgs |
570 |
test_name = test.rstrip() |
100 |
|
|
result = arg.__getattribute__(test_name)() |
101 |
jgs |
149 |
del result |
102 |
jgs |
148 |
|
103 |
|
|
# |
104 |
jgs |
149 |
# ===================== main ============================== |
105 |
jgs |
148 |
|
106 |
jgs |
153 |
msh=bruce.Rectangle(1000,1000) |
107 |
jgs |
148 |
|
108 |
jgs |
153 |
for wh in [Function(msh),ContinuousFunction(msh)]: |
109 |
jgs |
148 |
|
110 |
jgs |
153 |
print "\n", wh, ":" |
111 |
jgs |
148 |
|
112 |
jgs |
570 |
for ex in ["Constant", "Tagged", "Expanded"]: |
113 |
jgs |
148 |
|
114 |
|
|
for a in arglist: |
115 |
|
|
|
116 |
jgs |
570 |
arg=prepareArg(a,ex,wh) |
117 |
|
|
|
118 |
|
|
print "\n\t", ex, "Rank", arg.getRank(), "==>" |
119 |
jgs |
375 |
print "\n\t\tFunction\t\tElapsed time" |
120 |
|
|
print "\t\t--------\t\t------------" |
121 |
jgs |
148 |
|
122 |
jgs |
149 |
for test in testlist: |
123 |
jgs |
148 |
|
124 |
jgs |
149 |
starttime = getStartTime() |
125 |
jgs |
148 |
|
126 |
jgs |
149 |
runTest(arg,test) |
127 |
jgs |
148 |
|
128 |
jgs |
149 |
calcElapsedTime(starttime) |
129 |
jgs |
148 |
|
130 |
|
|
sys.exit(0) |
131 |
|
|
# end |