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

Last change on this file since 7802 was 7802, checked in by hudson, 12 years ago

Added James' laptop to profiling benchmark.

File size: 4.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
262009 June 22 - RW
27Changed the time/memory values to be exactly those found on the hardware.
28Took 10 measurements, used maximum in found values.
29
30"""
31
32import unittest
33import os, sys
34
35from anuga.fit_interpolate.benchmark_least_squares import BenchmarkLeastSquares
36
37class Test_uq(unittest.TestCase):
38    def setUp(self):
39        pass
40
41    def tearDown(self):
42        pass
43
44    # FIXME test the time to put .pts elevation into a domain object
45    # FIXME do tests for interpolate as well.
46
47    # A version round 4872 has slower times.
48    # That's because v4872 is using geo-ref, whereas the
49    # previous version did not.
50
51    def test_fit_time_and_mem(self):
52        import socket
53
54        # get hostname - for *nix and Windows
55        host = socket.gethostname()
56
57        # define dictionary of expected time/memory usage per machine.
58        # key must be unique *prefix* of machine name, lowercase.
59        # value is tuple: (time, memory) in seconds and KiB.
60        # On UNIX platforms, you can find the name by using the command
61        # hostname
62        expected_results = {'tornado':      (10.8, 40468),  # tornado headnode
63                            'cyclone':      (7.4,  40468),  # cyclone headnode
64                            'compute':      (10.8, 40468),  # cluster computenode
65                            'nautilus':     (8.1,  16104),  # Ole's 32bit Ubuntu
66                            'bogong':       (14.2, 30000),  # ANU?
67                            'pc-31569':     (31.6, 15000),  # DSG's PC?
68                            'pc-32572':     (12.8, 15788),  # Ross' 32bit work Ubuntu
69                            'saturn':       (12.8, 39404),  # Ross' 64bit home Ubuntu
70                            'desktop':      (27.0, 30000),   # Ole's 32 bit home Ubuntu (old)
71                            'ole-laptop':   (60.0, 30000)   # Ole's EEE Ubuntu netbook (900 MHz)
72                            'james-laptop': (45.0, 30000)   # Ole's EEE Ubuntu netbook (900 MHz)                           
73                           } 
74
75
76        # run trial, report on time and memory
77        ben = BenchmarkLeastSquares()
78        (time, mem, num_tri, quad_t) = ben.trial(num_of_points=1000,
79                                     maxArea=0.0001,
80                                     is_fit=True,
81                                     segments_in_mesh=False,
82                                     use_file_type='pts',
83                                     save=False
84                                    )
85
86        # Get expected machine values, else a default set of values
87        time_standard = 35.0        # max of above, plus a little
88        mem_standard = 40000
89        for key in expected_results:
90            if host.lower().startswith(key):
91                (time_standard, mem_standard) = expected_results[key]
92                break
93
94        # don't want exception here, report on time *and* memory
95        got_error = False
96        msg = ('Time used was %.1f s, standard is %.1f s +20%% (%.1f s)'
97               % (time, time_standard, int(time_standard*1.2)))
98        #print msg
99        #assert time < time_standard*1.2, msg
100        if time > time_standard*1.2:
101            print msg
102            got_error = True
103
104        if sys.platform == 'win32':
105            # Memory usage does not work on windows
106            return
107       
108        # Before change: https://datamining.anu.edu.au/anuga/changeset/5855
109        # which closed tickets 244 and 302, mem_standard was as above.
110        # Temporary until ticket:242 is fixed increase it by 25%
111        #mem_standard *= 1.25
112        # Ticket:242 is now fixed (19 Jan 2009), so mem_standard is
113        #reduced again
114
115        msg = ('Memory used was %d KiB, standard is %d KiB +20%% (%d KiB)'
116               % (mem, mem_standard, int(mem_standard*1.2)))
117        #print msg
118        assert mem < mem_standard*1.2, msg           
119
120        if got_error:
121            raise RuntimeError
122           
123#-------------------------------------------------------------
124if __name__ == "__main__":
125    suite = unittest.makeSuite(Test_uq,'test')
126    runner = unittest.TextTestRunner(verbosity=2)
127    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.