1 |
""" |
2 |
|
3 |
Load tests for escript/Data. |
4 |
|
5 |
Version $Id$ |
6 |
|
7 |
""" |
8 |
|
9 |
import sys |
10 |
import unittest |
11 |
import os |
12 |
|
13 |
import time |
14 |
|
15 |
from esys.escript import * |
16 |
from esys import bruce |
17 |
|
18 |
# ============================================================== |
19 |
|
20 |
arglist = [ \ |
21 |
[3,4], \ |
22 |
[[1,2],[3,4]], \ |
23 |
[[15,8],[12,8]], \ |
24 |
[[[15,8],[12,8]],[[-9,9],[13,8]]], \ |
25 |
3.0 \ |
26 |
] |
27 |
|
28 |
# ============================================================== |
29 |
|
30 |
def prepareArg(val,ex,wh): |
31 |
if ex=="Expanded": |
32 |
exx=True |
33 |
else: |
34 |
exx=False |
35 |
out=Data(val,what=wh,expand=exx) |
36 |
return out |
37 |
|
38 |
def doTest(a,ex,wh): |
39 |
|
40 |
arg=prepareArg(a,ex,wh) |
41 |
|
42 |
arg._wherePositive() |
43 |
arg._whereZero() |
44 |
arg._trace() |
45 |
arg._log() |
46 |
arg._Lsup() |
47 |
arg._maxval() |
48 |
arg._sign() |
49 |
|
50 |
arg+=arg |
51 |
arg-=arg |
52 |
arg*=arg |
53 |
arg/=arg |
54 |
|
55 |
# ============================================================== |
56 |
|
57 |
testNum = 0 |
58 |
|
59 |
totalTime = 0 |
60 |
|
61 |
for x0 in [1, 10, 100]: |
62 |
for x1 in [1, 10, 100]: |
63 |
|
64 |
print "#### x0:", x0, "#### x1:", x1, "####" |
65 |
msh=bruce.Rectangle(x0,x1) |
66 |
|
67 |
for wh in [ContinuousFunction(msh),Function(msh)]: |
68 |
|
69 |
for ex in ["Constant","Expanded"]: |
70 |
|
71 |
for a in arglist: |
72 |
|
73 |
testNum+=1 |
74 |
print testNum, ": ----------------------------------------------" |
75 |
|
76 |
testElapsed = 0 |
77 |
|
78 |
for j in range(10): |
79 |
|
80 |
starttime = time.clock() |
81 |
|
82 |
for i in range(1000): |
83 |
|
84 |
doTest(a,ex,wh) |
85 |
|
86 |
stoptime = time.clock() |
87 |
elapsed = stoptime - starttime |
88 |
testElapsed += elapsed |
89 |
totalTime += elapsed |
90 |
|
91 |
print elapsed |
92 |
|
93 |
print "Test elapsed time: ", testElapsed |
94 |
|
95 |
print "Total elapsed time: ", totalTime |
96 |
|
97 |
# end |