source: anuga_validation/automated_validation_tests/fitting/validate_benchmark_fit.py @ 6008

Last change on this file since 6008 was 6008, checked in by ole, 15 years ago

Minor fix in regard to the Win platform and fitting benchmark

File size: 3.9 KB
Line 
1"""Automatic verification that the ANUGA fitting code is not taking more time
2or memory than usual.  This test has been tailored for computers in GA.
3
4I'm leaving a 20% error margin
5
6Note, going from version 4897 to 4917 uses more memory, based on how
7memory is measured here. What is actually happening is the mesh
8generation is using less memory, in version 4917.  In version 4897
9mesh gen uses and frees up more memory, so python asks for less extra
10memory in the fitting stage.  So overall version 4917 is an
11improvement.
12
13RAW DATA
14 version 4897
15test_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
19version 4917
20test_fit_time_and_mem (__main__.Test_uq) ...  very start mem_usage() 98076
21 before fitting mem_usage() 120012
22 after fitting mem_usage() 150212
23time 15.19490695
24mem 30200
25
26"""
27
28import unittest
29import os, sys
30
31from anuga.fit_interpolate.benchmark_least_squares import BenchmarkLeastSquares
32
33class 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
103time 15.19490695
104mem 30200
105
106test_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
126        msg = 'Memory used was %f, mem_standard is %f' %(float(mem), mem_standard)
127        #print msg
128        assert mem<mem_standard*1.2, msg           
129           
130#-------------------------------------------------------------
131if __name__ == "__main__":
132    suite = unittest.makeSuite(Test_uq,'test')
133    runner = unittest.TextTestRunner(verbosity=2)
134    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.