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

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

Updated time and memory unit-test

File size: 3.7 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        if host.find('tornado') == 0:
65            # Tornado headnode
66            #time_standard = 14.5
67            time_standard = 24
68            mem_standard = 302404 
69           
70        elif host.find('compute-1') == 0: # cyclone or tornado node
71            time_standard = 19.0
72            mem_standard = 30204
73
74        elif host.find('cyclone') == 0: # cyclone headnode
75            time_standard = 13.3
76            mem_standard = 29424
77
78        elif host.find('nautilus') == 0:
79            time_standard = 27.6
80           
81            # v 4910 is giving a mem of 15572
82            mem_standard = 15572 
83           
84
85        elif host.find('bogong') == 0:
86            time_standard = 14.2
87            mem_standard = 30000 # Updated by Ole 20080507
88
89
90        elif host.find('pc-31569') == 0: # DSG's PC
91            time_standard = 31.6
92            mem_standard = 15000 #?
93
94            """
95            test_fit_time_and_mem (__main__.Test_uq) ...  very start mem_usage() 98076
96 before fitting mem_usage() 120012
97 after fitting mem_usage() 150212
98time 15.19490695
99mem 30200
100
101test_fit_time_and_mem (__main__.Test_uq) ...  very start mem_usage() 98108
102 before fitting mem_usage() 134696
103 after fitting mem_usage() 155820
104
105            """
106       
107        # Do the assertions here
108        assert time<time_standard*1.2
109
110       
111        # Before change: https://datamining.anu.edu.au/anuga/changeset/5855
112        # which closed tickets 244 and 302, mem_standard was as above.
113        # Temporary until ticket:242 is fixed increase it by 25%
114        mem_standard *= 1.25
115
116        msg = 'Memory used was %d, mem_standard is %d' %(mem, mem_standard)
117        #print msg
118        assert mem<mem_standard*1.2, msg           
119           
120#-------------------------------------------------------------
121if __name__ == "__main__":
122    suite = unittest.makeSuite(Test_uq,'test')
123    runner = unittest.TextTestRunner(verbosity=2)
124    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.