[4839] | 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 |
---|
[4919] | 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 |
---|
[5290] | 9 | mesh gen uses and frees up more memory, so python asks for less extra |
---|
[4919] | 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 | |
---|
[4839] | 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. |
---|
[4872] | 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. |
---|
[4839] | 47 | def test_fit_time_and_mem(self): |
---|
| 48 | import socket |
---|
| 49 | host = socket.gethostname() |
---|
| 50 | #print "host", host |
---|
| 51 | ben = BenchmarkLeastSquares() |
---|
[4861] | 52 | time, mem, num_tri, one_t, more_t, quad_t = ben.trial( |
---|
[4839] | 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 | ) |
---|
[5959] | 60 | |
---|
| 61 | |
---|
[4888] | 62 | #print "time", time |
---|
| 63 | #print "mem", mem |
---|
[6007] | 64 | |
---|
| 65 | #Defaults |
---|
[6008] | 66 | time_standard = 120. |
---|
[6007] | 67 | mem_standard = 50000. |
---|
| 68 | |
---|
[5986] | 69 | if host.find('tornado') == 0: |
---|
| 70 | # Tornado headnode |
---|
| 71 | #time_standard = 14.5 |
---|
[6007] | 72 | time_standard = 24. |
---|
| 73 | mem_standard = 302404. |
---|
[4839] | 74 | |
---|
[5986] | 75 | elif host.find('compute-1') == 0: # cyclone or tornado node |
---|
[4872] | 76 | time_standard = 19.0 |
---|
[6007] | 77 | mem_standard = 30204. |
---|
[4839] | 78 | |
---|
| 79 | elif host.find('cyclone') == 0: # cyclone headnode |
---|
[4872] | 80 | time_standard = 13.3 |
---|
[6007] | 81 | mem_standard = 29424. |
---|
[4839] | 82 | |
---|
[4840] | 83 | elif host.find('nautilus') == 0: |
---|
[4873] | 84 | time_standard = 27.6 |
---|
[5959] | 85 | |
---|
| 86 | # v 4910 is giving a mem of 15572 |
---|
[6007] | 87 | mem_standard = 15572. |
---|
[5959] | 88 | |
---|
[4840] | 89 | |
---|
[4880] | 90 | elif host.find('bogong') == 0: |
---|
| 91 | time_standard = 14.2 |
---|
[6007] | 92 | mem_standard = 30000. # Updated by Ole 20080507 |
---|
[4880] | 93 | |
---|
[5959] | 94 | |
---|
[4839] | 95 | elif host.find('pc-31569') == 0: # DSG's PC |
---|
[4872] | 96 | time_standard = 31.6 |
---|
[6007] | 97 | mem_standard = 15000. #? |
---|
[4919] | 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 | """ |
---|
[5959] | 111 | |
---|
| 112 | # Do the assertions here |
---|
| 113 | assert time<time_standard*1.2 |
---|
| 114 | |
---|
[6007] | 115 | |
---|
| 116 | |
---|
| 117 | if sys.platform == 'win32': |
---|
| 118 | # Memory usage does not work on windows |
---|
| 119 | return |
---|
[5959] | 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% |
---|
[6198] | 124 | #mem_standard *= 1.25 |
---|
| 125 | # Ticket:242 is now fixed (19 Jan 2009), so mem_standard is |
---|
| 126 | #reduced again |
---|
[5959] | 127 | |
---|
[6007] | 128 | msg = 'Memory used was %f, mem_standard is %f' %(float(mem), mem_standard) |
---|
[5959] | 129 | #print msg |
---|
| 130 | assert mem<mem_standard*1.2, msg |
---|
[4839] | 131 | |
---|
| 132 | #------------------------------------------------------------- |
---|
| 133 | if __name__ == "__main__": |
---|
| 134 | suite = unittest.makeSuite(Test_uq,'test') |
---|
| 135 | runner = unittest.TextTestRunner(verbosity=2) |
---|
| 136 | runner.run(suite) |
---|