Index: /anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py	(revision 4648)
@@ -20,4 +20,6 @@
 import time
 from random import seed, random
+import tempfile
+import profile , pstats
 import tempfile
 
@@ -71,9 +73,9 @@
               segments_in_mesh=True,
               save=False,
-              verbose=False):
+              verbose=False,
+              run_profile=False):
         '''
         num_of_points 
         '''
-        
         #print "num_of_points",num_of_points
         #print "maxArea",maxArea
@@ -89,5 +91,10 @@
         #m0 = None on windows
         m0 = mem_usage()
-
+        
+        profile_file = "P" + str(num_of_points) + \
+                       "T" + str(len(mesh_dict['triangles'])) + \
+                       "PPC" + str(max_points_per_cell) + \
+                       ".txt"
+                       
         if use_least_squares is True:
             from anuga.where.least_squares import Interpolation
@@ -108,4 +115,5 @@
         else: 
             if is_fit is True:
+                from anuga.fit_interpolate.fit import Fit
                 interp = Fit(mesh_dict['vertices'],
                                  mesh_dict['triangles'], 
@@ -121,5 +129,26 @@
                                          points_dict['point_attributes'])
                     G1.export_points_file(fileName, absolute=True)
-                    calc = interp.fit(fileName, verbose=verbose)
+
+                    if run_profile:
+                    
+                        s = """interp.fit(fileName, verbose=verbose)"""
+                        pobject = profile.Profile()
+                        presult = pobject.runctx(s,
+                                                 vars(sys.modules[__name__]),
+                                                 vars())
+                        prof_file = tempfile.mktemp(".prof")
+                        presult.dump_stats(prof_file)
+                        #
+                        # Let process these results
+                        S = pstats.Stats(prof_file)
+                        saveout = sys.stdout 
+                        pfile = open(profile_file, "w")
+                        sys.stdout = pfile
+                        s = S.sort_stats('cumulative').print_stats(30)
+                        sys.stdout = saveout 
+                        pfile.close()
+                        os.remove(prof_file)
+                    else:
+                        interp.fit(fileName, verbose=verbose)
                     os.remove(fileName)
                     
@@ -131,8 +160,19 @@
                                      mesh_dict['triangles'], 
                                  max_vertices_per_cell = max_points_per_cell)
-                calc = interp.interpolate(mesh_dict['vertex_attributes']
+                s = """calc = interp.interpolate(mesh_dict['vertex_attributes']
                                           ,points_dict['points']
-                                          ,start_blocking_len=blocking_len)
-            
+                                          ,start_blocking_len=blocking_len)"""
+                
+                fileName = tempfile.mktemp(".prof")
+                profile.run(s, fileName) #profile_file)
+                
+                S = pstats.Stats(fileName)
+                s = S.sort_stats('cumulative').print_stats(30)
+                print "***********"
+                print s
+                print "***********"
+                pfile = file.open(profile_file, "w")
+                pfile.write(s)
+                pfile.close()
         time_taken_sec = (time.time()-t0)
         m1 = mem_usage()
Index: /anuga_core/source/anuga/fit_interpolate/fit.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4648)
@@ -436,5 +436,5 @@
 def fit_to_mesh(vertex_coordinates,
                 triangles,
-                point_coordinates, # this can also be a .csv/.txt file name
+                point_coordinates, # this can also be a points file name
                 point_attributes=None,
                 alpha=DEFAULT_ALPHA,
Index: /anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/general_fit_interpolate.py	(revision 4648)
@@ -91,4 +91,5 @@
         
         if verbose: print 'FitInterpolate: Building quad tree'
+        # This stores indices of vertices
         self.root = build_quadtree(self.mesh,
                                    max_points_per_cell = max_vertices_per_cell)
Index: /anuga_core/source/anuga/fit_interpolate/interpolate.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/interpolate.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/interpolate.py	(revision 4648)
@@ -241,9 +241,5 @@
         #Convert point_coordinates to Numeric arrays, in case it was a list.
         point_coordinates = ensure_numeric(point_coordinates, Float)
-        # for ticket 160
-	#boundary = self.mesh.get_boundary_polygon()
-        #geo = Geospatial_data(boundary)
-        #geo.export_points_file('serial-boundary.xya')
-        #geo.export_points_file('serial-boundary.txt')
+        
         if verbose: print 'Getting indices inside mesh boundary'
         self.inside_poly_indices, self.outside_poly_indices  = \
@@ -251,6 +247,5 @@
                                             self.mesh.get_boundary_polygon(),
                                             closed = True, verbose = verbose)
-        #print "self.inside_poly_indices",self.inside_poly_indices
-        #print "self.outside_poly_indices",self.outside_poly_indices 
+        
         #Build n x m interpolation matrix
         if verbose and len(self.outside_poly_indices) > 0:
Index: /anuga_core/source/anuga/fit_interpolate/test_search_functions.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/test_search_functions.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/test_search_functions.py	(revision 4648)
@@ -161,14 +161,5 @@
                 assert found is True
             else:
-                assert found is False                
-            
-
-        
-                
-
-        
-        
-
-        
+                assert found is False   
 #-------------------------------------------------------------
 if __name__ == "__main__":
Index: /anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py
===================================================================
--- /anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py	(revision 4647)
+++ /anuga_core/source/anuga/fit_interpolate/ticket178_benchmark.py	(revision 4648)
@@ -17,8 +17,13 @@
 use_least_squares_list = [False]
 is_fit_list = [True]
-num_of_points_list = [200, 600, 2000, 6000, 10000, 20000]  #[5000] #, 500] #, 10000, 100000] #, 10000000]
+num_of_points_list = [200, 600, 2000, 6000, 10000, 20000] 
 maxArea_list = [ 0.008, 0.0016, 0.0008]
-max_points_per_cell_list = [2,4,8,16,30,64] #,4,8,16,32,64,128,255]
+max_points_per_cell_list = [2,4,8,16,30,64]
 use_file_type_list = ['pts']
+
+
+num_of_points_list = [200] 
+maxArea_list = [ 0.008]
+max_points_per_cell_list = [30]
 
 fd = open(ofile,'a')
@@ -48,4 +53,5 @@
                                                    ,use_file_type=use_file_type
                                                    ,save=True
+                                                   ,run_profile=True
                                                )
                     print "time",time
