1 | """Automatic verification that the ANUGA fitting code is not taking more time |
---|
2 | or memory than usual. This test has been tailored for computers in GA. |
---|
3 | |
---|
4 | I'm leaving a 20% error margin |
---|
5 | |
---|
6 | Note, going from version 4897 to 4917 uses more memory, based on how |
---|
7 | memory is measured here. What is actually happening is the mesh |
---|
8 | generation is using less memory, in version 4917. In version 4897 |
---|
9 | mesh gen uses and frees up more memory, so python asks for less extra |
---|
10 | memory in the fitting stage. So overall version 4917 is an |
---|
11 | improvement. |
---|
12 | |
---|
13 | RAW DATA |
---|
14 | version 4897 |
---|
15 | test_fit_time_and_mem (__main__.Test_uq) ... very start mem_usage() 98108 |
---|
16 | before fitting mem_usage() 134696 |
---|
17 | after fitting mem_usage() 155820 |
---|
18 | |
---|
19 | version 4917 |
---|
20 | test_fit_time_and_mem (__main__.Test_uq) ... very start mem_usage() 98076 |
---|
21 | before fitting mem_usage() 120012 |
---|
22 | after fitting mem_usage() 150212 |
---|
23 | time 15.19490695 |
---|
24 | mem 30200 |
---|
25 | |
---|
26 | """ |
---|
27 | |
---|
28 | import unittest |
---|
29 | import os, sys |
---|
30 | |
---|
31 | from anuga.fit_interpolate.benchmark_least_squares import BenchmarkLeastSquares |
---|
32 | |
---|
33 | class Test_uq(unittest.TestCase): |
---|
34 | def setUp(self): |
---|
35 | pass |
---|
36 | |
---|
37 | |
---|
38 | def tearDown(self): |
---|
39 | pass |
---|
40 | |
---|
41 | # FIXME test the time to put .pts elevation into a domain object |
---|
42 | # FIXME do tests for interpolate as well. |
---|
43 | |
---|
44 | # A version round 4872 has slower times. |
---|
45 | # That's because v4872 is using geo-ref, whereas the |
---|
46 | # previous version did not. |
---|
47 | def test_fit_time_and_mem(self): |
---|
48 | import socket |
---|
49 | host = socket.gethostname() |
---|
50 | #print "host", host |
---|
51 | ben = BenchmarkLeastSquares() |
---|
52 | time, mem, num_tri, one_t, more_t, quad_t = ben.trial( |
---|
53 | num_of_points=1000 |
---|
54 | ,maxArea=0.0001 |
---|
55 | ,is_fit=True |
---|
56 | ,segments_in_mesh=False |
---|
57 | ,use_file_type='pts' |
---|
58 | ,save=False |
---|
59 | ) |
---|
60 | |
---|
61 | |
---|
62 | #print "time", time |
---|
63 | #print "mem", mem |
---|
64 | |
---|
65 | #Defaults |
---|
66 | time_standard = 120. |
---|
67 | mem_standard = 50000. |
---|
68 | |
---|
69 | if host.find('tornado') == 0: |
---|
70 | # Tornado headnode |
---|
71 | #time_standard = 14.5 |
---|
72 | time_standard = 24. |
---|
73 | mem_standard = 302404. |
---|
74 | |
---|
75 | elif host.find('compute-1') == 0: # cyclone or tornado node |
---|
76 | time_standard = 19.0 |
---|
77 | mem_standard = 30204. |
---|
78 | |
---|
79 | elif host.find('cyclone') == 0: # cyclone headnode |
---|
80 | time_standard = 13.3 |
---|
81 | mem_standard = 29424. |
---|
82 | |
---|
83 | elif host.find('nautilus') == 0: |
---|
84 | time_standard = 27.6 |
---|
85 | |
---|
86 | # v 4910 is giving a mem of 15572 |
---|
87 | mem_standard = 15572. |
---|
88 | |
---|
89 | |
---|
90 | elif host.find('bogong') == 0: |
---|
91 | time_standard = 14.2 |
---|
92 | mem_standard = 30000. # Updated by Ole 20080507 |
---|
93 | |
---|
94 | |
---|
95 | elif host.find('pc-31569') == 0: # DSG's PC |
---|
96 | time_standard = 31.6 |
---|
97 | mem_standard = 15000. #? |
---|
98 | |
---|
99 | """ |
---|
100 | test_fit_time_and_mem (__main__.Test_uq) ... very start mem_usage() 98076 |
---|
101 | before fitting mem_usage() 120012 |
---|
102 | after fitting mem_usage() 150212 |
---|
103 | time 15.19490695 |
---|
104 | mem 30200 |
---|
105 | |
---|
106 | test_fit_time_and_mem (__main__.Test_uq) ... very start mem_usage() 98108 |
---|
107 | before fitting mem_usage() 134696 |
---|
108 | after fitting mem_usage() 155820 |
---|
109 | |
---|
110 | """ |
---|
111 | |
---|
112 | # Do the assertions here |
---|
113 | assert time<time_standard*1.2 |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | if sys.platform == 'win32': |
---|
118 | # Memory usage does not work on windows |
---|
119 | return |
---|
120 | |
---|
121 | # Before change: https://datamining.anu.edu.au/anuga/changeset/5855 |
---|
122 | # which closed tickets 244 and 302, mem_standard was as above. |
---|
123 | # Temporary until ticket:242 is fixed increase it by 25% |
---|
124 | #mem_standard *= 1.25 |
---|
125 | # Ticket:242 is now fixed (19 Jan 2009), so mem_standard is |
---|
126 | #reduced again |
---|
127 | |
---|
128 | msg = 'Memory used was %f, mem_standard is %f' %(float(mem), mem_standard) |
---|
129 | #print msg |
---|
130 | assert mem<mem_standard*1.2, msg |
---|
131 | |
---|
132 | #------------------------------------------------------------- |
---|
133 | if __name__ == "__main__": |
---|
134 | suite = unittest.makeSuite(Test_uq,'test') |
---|
135 | runner = unittest.TextTestRunner(verbosity=2) |
---|
136 | runner.run(suite) |
---|