Index: inundation/fit_interpolate/benchmark_least_squares.py
===================================================================
--- inundation/fit_interpolate/benchmark_least_squares.py	(revision 1974)
+++ inundation/fit_interpolate/benchmark_least_squares.py	(revision 2004)
@@ -16,13 +16,11 @@
 
 
-import unittest
-from math import sqrt
+import os
+import sys
 import time
-
+from random import seed, random
 
 from pyvolution.least_squares import Interpolation
-from Numeric import allclose, array, transpose
-import os
-import sys
+from pmesh.mesh import Mesh
 
 def mem_usage():
@@ -48,105 +46,21 @@
 
 
-class Test_Least_Squares(unittest.TestCase):
+class BenchmarkLeastSquares:
 
-    def setUp(self):
+
+    def __init__(self):
         pass
 
-    def tearDown(self):
-        pass
+    def trial(self,
+              num_of_points=20000,
+              maxArea=1000,
+              max_points_per_cell=4,
+              save=False):
+        #print "num_of_points",num_of_points
+        #print "maxArea",maxArea
+        #print "max_points_per_cell", max_points_per_cell
 
-    def ztest_expand_search2(self):
-        from random import seed, random
-        from pmesh.mesh import Mesh
-        
-        seed(2)
-        m = Mesh()
-        verts_per_sector = 100 #100
-        num_of_points = 300
-        sec_side = 9.0
-
-        vert_atts = []
-        for vert in range(verts_per_sector):
-            m.addUserVertex(random()*sec_side, random()*sec_side)
-            vert_atts.append(random())
-        for vert in range(verts_per_sector):
-            m.addUserVertex(90.0+random()*sec_side, 90.0+random()*sec_side)
-            vert_atts.append(random())
-        for vert in range(verts_per_sector):
-            m.addUserVertex(random()*sec_side, 90.0+random()*sec_side)
-            vert_atts.append(random())
-        for vert in range(verts_per_sector):
-            m.addUserVertex(90.0+random()*sec_side, random()*sec_side)
-            vert_atts.append(random())
-        #for vert in range(verts_per_sector):
-        #    m.addUserVertex(40.0+random()*sec_side, 40.0+random()*sec_side)
-        #    vert_atts.append(random())
-            
-        m.autoSegment(alpha = 100 )
-        m.generateMesh(mode = "Q")
-        m.export_mesh_file("aaaa.tsh")
-        mesh_dict =  m.Mesh2IOTriangulationDict()
-
-        points = []
-        point_atts = []
-        for point in range(num_of_points):
-            points.append([random()*100, random()*100])
-            point_atts.append(10.0)
-        m.autoSegment(alpha = 100 )
-
-        #print 'points', points
-        t0 = time.time()
-
-        interp = Interpolation(mesh_dict['vertices'],
-                               mesh_dict['triangles'], points,
-                               alpha=0.2, expand_search=True,
-                               verbose = False,
-                               max_points_per_cell = 4)
-        calc = interp.fit_points(point_atts )
-        #print "interp.expanded_quad_searches", interp.expanded_quad_searches
-        #print "calc", calc
-        print 'That took %.2f seconds' %(time.time()-t0)
-
-        
-    def test_expand_search3(self):
-        from random import seed, random
-        from pmesh.mesh import Mesh
-
-        # takes 7.73 seconds
-        #num_of_points = 20000
-        #maxArea = 1000
-        #max_points_per_cell = 4
-
-        # took 9.84 secs
-        #num_of_points = 20000
-        #maxArea = 100
-        #max_points_per_cell = 4
-
-        # 16.61 secs
-        num_of_points = 20000
-        maxArea = 10 #836 basis functions
-        #max_points_per_cell = 4 #16.61 sec
-        
-        #max_points_per_cell = 30 #31.17 sec
-        #max_points_per_cell = 2 #16.125 sec
-        max_points_per_cell = 8 #17.66 sec
-
-        
-        # 16.61 secs
-        num_of_points = 20000
-        maxArea = 1 #7917 basis functions
-        max_points_per_cell = 4 # 76.047 sec
-        
-        #max_points_per_cell = 30 #
-        #max_points_per_cell = 2 #78.97 sec
-        #max_points_per_cell = 16 # 82.33 sec
-        #max_points_per_cell = 8 #77.984 sec
-        
-        # 8.44 secs
-        #num_of_points = 20000
-        #maxArea = 1
-        
-        
-        seed(2)
+        # make a mesh
+        # pretty regular size, with some segments thrown in. 
         m = Mesh()
         m.addUserVertex(0,0)
@@ -180,8 +94,8 @@
         dict['segment_tags'] = ['wall4']   
         m.addVertsSegs(dict)
-        
-        m.addVertsSegs(dict)
-        m.generateMesh(mode = "Q", maxArea = maxArea)
-        m.export_mesh_file("aaaa.tsh")
+
+        m.generateMesh(mode = "Q", maxArea = maxArea)       
+        if save is True:
+            m.export_mesh_file("aaaa.tsh")
         mesh_dict =  m.Mesh2IOTriangulationDict()
 
@@ -191,24 +105,24 @@
             points.append([random()*100, random()*100])
             point_atts.append(10.0)
-        #m.autoSegment(alpha = 100 )
+            
+        #Initial time and memory
+        t0 = time.time()
+        #m0 = None on windows
+        m0 = mem_usage()
 
-        #print 'points', points
-        t0 = time.time()
         interp = Interpolation(mesh_dict['vertices'],
                                mesh_dict['triangles'], points,
                                alpha=0.2, expand_search=True,
-                               verbose = True, #False,
-                               max_points_per_cell = max_points_per_cell)
+                               verbose = False,
+                               max_points_per_cell = 4)
         calc = interp.fit_points(point_atts )
-        print "interp.expanded_quad_searches", interp.expanded_quad_searches
+        #print "interp.expanded_quad_searches", interp.expanded_quad_searches
         #print "calc", calc
-        print 'That took %.2f seconds' %(time.time()-t0)
-        
-#-------------------------------------------------------------
-if __name__ == "__main__":
-    import os
-    suite = unittest.makeSuite(Test_Least_Squares,'test')
-    runner = unittest.TextTestRunner(verbosity=1)
-    runner.run(suite)
-    val = mem_usage()
-    print 'RSS', val
+        time_taken_sec = (time.time()-t0)
+        m1 = mem_usage()
+        if m0 is None or m1 is None:
+            memory_used = None
+        else:
+            memory_used = (m1 - m0)
+        #print 'That took %.2f seconds' %time_taken_sec
+        return time_taken_sec, memory_used
