[pypy-svn] r59751 - pypy/build/benchmem

xoraxax at codespeak.net xoraxax at codespeak.net
Thu Nov 6 23:39:16 CET 2008


Author: xoraxax
Date: Thu Nov  6 23:39:15 2008
New Revision: 59751

Modified:
   pypy/build/benchmem/runbench.py
Log:
Trigger compilation using an import statement in the appprofiles runner.

Modified: pypy/build/benchmem/runbench.py
==============================================================================
--- pypy/build/benchmem/runbench.py	(original)
+++ pypy/build/benchmem/runbench.py	Thu Nov  6 23:39:15 2008
@@ -210,23 +210,19 @@
             self.run_once(name)
             
     def run_once(self, name):
-        benchpyfile = self.makebench(name)
+        benchpyfile, runner_file = self.makebench(name)
         #self.log("created", benchpyfile)
-        cmd = "%s -u %s" %(self.executable, benchpyfile)
+        cmd = "%s -u "% (self.executable, )
         self.log("running %s(%s)" %(name, self.options.numiter))
 
         # we want to avoid measuring the size impact of
         # compiler invocation, so we have to manually compile
         # the modules and hope
 
-        # first compile the dependencies of the module
-        os.system(cmd + " --importonly")
-        # then compile the module itself
-        compile_cmd = 'from py_compile import compile; compile("%s")' % (str(benchpyfile), )
-        compile_cmdline = "%s -c '%s'" % (self.executable, compile_cmd)
-        os.system(compile_cmdline)
+        # first compile the modules by importing a module that imports
+        os.system(cmd + str(runner_file))
 
-        stdout, stdin = os.popen2(cmd)
+        stdout, stdin = os.popen2(cmd + str(benchpyfile))
         pid = int(stdin.readline())
         self.write_benchheader(name, self.options.numiter)
         rec = smaps.SmapsRecorder(pid, self.logstream)
@@ -236,6 +232,12 @@
 
     def makebench(self, name):
         arglist = (int(self.options.numiter), self.ITER2)
+        runner_file = self.tmpdir.join("runner.py")
+        runner_file.write(py.code.Source("""
+            import sys
+            sys.path.append(%r)
+            import %s
+        """ % (str(self.tmpdir), self.benchpath.basename[:-3])))
         source = py.code.Source(self.getbenchsource(), """
             import gc
             def write(c):
@@ -254,7 +256,7 @@
         """ %(name, arglist))
         p = self.tmpdir.join(self.benchpath.basename)
         p.write(source)
-        return p
+        return p, runner_file
     
     def interact_with_child(self, rec, stdin, stdout):
         while not stdin.closed:



More information about the Pypy-commit mailing list