/[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 570 - (hide annotations)
Tue Feb 28 06:51:25 2006 UTC (13 years, 7 months ago) by jgs
File MIME type: text/x-python
File size: 2191 byte(s)
extend these tests to test DataTagged objecrs also
1 jgs 149 """
2     Miscellaneous escript/Data timing tests.
3    
4     Version $Id$
5     """
6    
7 jgs 148 import sys
8     import os
9     import time
10    
11 jgs 149 from esys.escript import *
12 jgs 153 from esys import bruce
13 jgs 148
14 jgs 149 #
15     # ================== data values to test with =========================
16 jgs 148
17     arglist = [ \
18     3.0, \
19 jgs 149 [3.0,4.0], \
20     [[1.0,2.0],[3.0,4.0]], \
21 jgs 570 [[[15.0,8.0],[12.0,8.0]],[[-9.0,9.0],[13.0,8.0]]], \
22     [[[[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]]]] \
23 jgs 148 ]
24    
25 jgs 149 testlist = [
26 jgs 570 "_trace ",
27     "_maxval ",
28     "_minval ",
29     "_wherePositive ",
30     "_whereNegative ",
31     "_whereNonNegative",
32     "_whereNonPositive",
33     "_whereZero ",
34     "_whereNonZero ",
35     "_sin ",
36     "_cos ",
37     "_tan ",
38     "_asin ",
39     "_acos ",
40     "_atan ",
41     "_sinh ",
42     "_cosh ",
43     "_tanh ",
44     "_asinh ",
45     "_acosh ",
46     "_atanh ",
47     "_exp ",
48     "_sqrt ",
49     "_log10 ",
50     "_log ",
51     "_sign ",
52     "_Lsup ",
53     "_sup ",
54     "_inf "
55 jgs 149 ]
56 jgs 148
57 jgs 149 #
58     # ================== method definitions =========================
59    
60 jgs 148 def prepareArg(val,ex,wh):
61 jgs 149 if ex=="Expanded":
62     exx=True
63     else:
64     exx=False
65     out=Data(val,what=wh,expand=exx)
66 jgs 570 if ex=="Tagged":
67     out.tag()
68 jgs 149 return out
69 jgs 148
70 jgs 149 def getStartTime():
71     return time.clock()
72 jgs 148
73 jgs 149 def calcElapsedTime(starttime):
74     stoptime = time.clock()
75     elapsed = stoptime - starttime
76 jgs 153 print "\t\t", elapsed
77 jgs 148
78 jgs 149 def runTest(arg,test):
79 jgs 153 print "\t\t", test,
80 jgs 570 test_name = test.rstrip()
81     result = arg.__getattribute__(test_name)()
82 jgs 149 del result
83 jgs 148
84     #
85 jgs 149 # ===================== main ==============================
86 jgs 148
87 jgs 153 msh=bruce.Rectangle(1000,1000)
88 jgs 148
89 jgs 153 for wh in [Function(msh),ContinuousFunction(msh)]:
90 jgs 148
91 jgs 153 print "\n", wh, ":"
92 jgs 148
93 jgs 570 for ex in ["Constant", "Tagged", "Expanded"]:
94 jgs 148
95     for a in arglist:
96    
97 jgs 570 arg=prepareArg(a,ex,wh)
98    
99     print "\n\t", ex, "Rank", arg.getRank(), "==>"
100 jgs 375 print "\n\t\tFunction\t\tElapsed time"
101     print "\t\t--------\t\t------------"
102 jgs 148
103 jgs 149 for test in testlist:
104 jgs 148
105 jgs 149 starttime = getStartTime()
106 jgs 148
107 jgs 149 runTest(arg,test)
108 jgs 148
109 jgs 149 calcElapsedTime(starttime)
110 jgs 148
111     sys.exit(0)
112     # end

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26