Commits

Matthew Turk  committed 00c10bc

Adding .hgignore, some updates to the testing.

  • Participants
  • Parent commits fef0f42

Comments (0)

Files changed (3)

+syntax: glob
+*.cprof
+*.pyc

File profile_support.py

     path = os.path.dirname(yt_provider.module_path)
     vc_type = cl._get_vcs_type(path)
     vstring = cl._vcs_identifier[vc_type](path)
-    my_version = vstring.replace("(", "").replace(")","").replace(" ", "_")
+    my_version = vstring.replace("(", "").replace(")","").replace(" ", "_").strip()
     return my_version
 
 _my_version = get_version_string()
     functions_to_profile[func.func_name] = func
     return func
 
+class StatefulProfileRunner:
+    # Something about the way cProfile operates and interacts with globals and
+    # locals doesn't like the execution from within run_all_tests.  So we
+    # create this object, of which there will only be one, and it can have
+    # functions associated with it.
+    def __init__(self):
+        self.func = lambda a: None
+
+    def run(self, pf):
+        self.func(pf)
+
+profile_runner = StatefulProfileRunner()
+
 def run_all_tests(pf, ntimes = 1):
     from mpi4py import MPI
     rank = MPI.COMM_WORLD.rank
     for fname in sorted(functions_to_profile):
         print "HANDLING %s on %s / %s" % (
             fname, rank, size)
-        ofn = "%s_%s_%03i_%03i" % (
+        ofn = "%s_%s_%03i_%03i.cprof" % (
             fname, _my_version, size, rank)
         times = []
-        func = functions_to_profile[fname]
+        profile_runner.func = functions_to_profile[fname]
         for n in xrange(ntimes):
+            def new_func():
+                func(pf)
             MPI.COMM_WORLD.Barrier()
             t1 = time.time()
-            cProfile.run("func(pf)", ofn)
+            cProfile.run("profile_runner.run(pf)", ofn)
             MPI.COMM_WORLD.Barrier()
             t2 = time.time()
             times.append(t2-t1)
         results[fname] = (na.min(times), na.max(times), na.average(times))
+        if MPI.COMM_WORLD.rank == 0:
+            print "Results [%s]: %0.3e %0.3e %0.3e" % (
+                fname, results[fname][0], results[fname][1], results[fname][2])
     return results

File run_profiling.py

 ytcfg["yt","serialize"] = "False"
 
 from yt.mods import *
-from profile_support import profile_test, run_all_tests
+from profile_support import profile_test, run_all_tests, profile_runner
 
 @profile_test
 def aaa_hierarchy(pf):
                            lazy_reader = True)
     prof.add_fields(["CellMassMsun"], weight=None)
 
-pf = load("../DD0083/DD0083")
+#pf = load("../DD0083/DD0083", data_style="enzo_packed_3d")
+pf = load("/nics/d/home/davem/turk/tar1/DD0083/DD0083")
 
 run_all_tests(pf, 1)