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

Last change on this file since 7223 was 7223, checked in by rwilson, 15 years ago

Merged changes from numpy branch.

File size: 4.3 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 = 30204 
74           
75        elif host.find('compute') == 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 = 30204
82            #mem_standard = 29424
83
84        elif host.find('nautilus') == 0:
85            time_standard = 27.6
86           
87            # v 4910 is giving a mem of 15572
88            mem_standard = 15572 
89           
90
91        elif host.find('bogong') == 0:
92            time_standard = 14.2
93            mem_standard = 30000 # Updated by Ole 20080507
94
95
96        elif host.find('pc-31569') == 0: # DSG's PC
97            time_standard = 31.6
98            mem_standard = 15000 #?
99
100        elif host.find('PC-32572') == 0: # Ross' Ubuntu box - nump trunk
101            time_standard = 12.8
102            mem_standard = 15788 #?
103
104            """
105            test_fit_time_and_mem (__main__.Test_uq) ...  very start mem_usage() 98076
106 before fitting mem_usage() 120012
107 after fitting mem_usage() 150212
108time 15.19490695
109mem 30200
110
111test_fit_time_and_mem (__main__.Test_uq) ...  very start mem_usage() 98108
112 before fitting mem_usage() 134696
113 after fitting mem_usage() 155820
114
115            """
116       
117        # Do the assertions here
118        msg = ('Time used was %.1f s, standard is %.1f s +20%% (%.1f s)'
119               % (time, time_standard, int(time_standard*1.2)))
120        assert time < time_standard*1.2, msg
121
122
123
124        if sys.platform == 'win32':
125            # Memory usage does not work on windows
126            return
127       
128        # Before change: https://datamining.anu.edu.au/anuga/changeset/5855
129        # which closed tickets 244 and 302, mem_standard was as above.
130        # Temporary until ticket:242 is fixed increase it by 25%
131        #mem_standard *= 1.25
132        # Ticket:242 is now fixed (19 Jan 2009), so mem_standard is
133        #reduced again
134
135        msg = ('Memory used was %d KiB, standard is %d KiB +20%% (%d KiB)'
136               % (mem, mem_standard, int(mem_standard*1.2)))
137        assert mem < mem_standard*1.2, msg           
138           
139#-------------------------------------------------------------
140if __name__ == "__main__":
141    suite = unittest.makeSuite(Test_uq,'test')
142    runner = unittest.TextTestRunner(verbosity=2)
143    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.