[pypy-svn] r49925 - pypy/dist/pypy/translator/microbench

arigo at codespeak.net arigo at codespeak.net
Wed Dec 19 11:42:45 CET 2007


Author: arigo
Date: Wed Dec 19 11:42:44 2007
New Revision: 49925

Modified:
   pypy/dist/pypy/translator/microbench/microbench.py
Log:
For now, tweak the microbench runner so that the global data
for all test_* modules are not all loaded in the process
at the same time.  This allows us to add new test_* modules
with large global data (e.g. test_unicode) without affecting
the overall process' memory usage.  This is what caused
test_list_extend's performance to suddenly drop.


Modified: pypy/dist/pypy/translator/microbench/microbench.py
==============================================================================
--- pypy/dist/pypy/translator/microbench/microbench.py	(original)
+++ pypy/dist/pypy/translator/microbench/microbench.py	Wed Dec 19 11:42:44 2007
@@ -6,19 +6,25 @@
 
 import os, time, sys, gc
 
+try:
+    this_dir = os.path.dirname(__file__)
+except NameError:
+    this_dir = os.path.dirname(sys.argv[0])
+
 microbenches = []
 for fname in os.listdir('.'):
     if not fname.startswith('test_') or not fname.endswith('.py'):
         continue
     microbench = fname[:-3]
-    exec 'import ' + microbench
     microbenches.append(microbench)
 
 def run(test_cases):
     MINIMUM_MICROBENCH_TIME = 1.0
 
     for microbench in microbenches:
-        for k in [s for s in globals()[microbench].__dict__ if s.startswith('test_')] :
+        testmoddict = {}
+        execfile(os.path.join(this_dir, microbench + '.py'), testmoddict)
+        for k in [s for s in testmoddict if s.startswith('test_')] :
             if test_cases:
                 for tc in test_cases:
                     if k.startswith(tc):
@@ -26,7 +32,7 @@
                 else:
                     continue
             testcase_name = microbench + '.' + k + '()'
-            testcase = getattr(globals()[microbench], k)
+            testcase = testmoddict[k]
             gc.collect()
             start = time.clock()
             n = 0



More information about the Pypy-commit mailing list