[pypy-commit] pypy reflex-support: update to new interp interface and bench for PyROOT

wlav noreply at buildbot.pypy.org
Thu Jul 21 14:05:58 CEST 2011


Author: Wim Lavrijsen <WLavrijsen at lbl.gov>
Branch: reflex-support
Changeset: r45809:dbf532b2eb5c
Date: 2011-07-19 06:50 -0700
http://bitbucket.org/pypy/pypy/changeset/dbf532b2eb5c/

Log:	update to new interp interface and bench for PyROOT

diff --git a/pypy/module/cppyy/test/bench1.py b/pypy/module/cppyy/test/bench1.py
--- a/pypy/module/cppyy/test/bench1.py
+++ b/pypy/module/cppyy/test/bench1.py
@@ -15,7 +15,7 @@
 
 def print_bench(name, t_bench):
     global t_cppref
-    print ':::: %s cost: %#6.3fs (%#4dx)' % (name, t_bench, t_bench/t_cppref)
+    print ':::: %s cost: %#6.3fs (%#4.1fx)' % (name, t_bench, float(t_bench)/t_cppref)
 
 def python_loop_offset():
     for i in range(NNN):
@@ -40,6 +40,14 @@
             instance.addDataToInt(i)
         return i
 
+class PyROOTBench1(PyCintexBench1):
+    def __init__(self):
+        import ROOT
+        self.lib = ROOT.gSystem.Load("./example01Dict_cint.so")
+
+        self.cls   = ROOT.example01
+        self.inst  = self.cls(0)
+
 class CppyyInterpBench1(object):
     scale = 1
     def __init__(self):
@@ -47,15 +55,13 @@
         self.lib = cppyy.load_lib("./example01Dict.so")
 
         self.cls  = cppyy._type_byname("example01")
-        self.inst = self.cls.construct(0)
+        self.inst = self.cls.get_overload(self.cls.type_name).call(None, cppyy.CPPInstance, 0)
 
     def __call__(self):
         addDataToInt = self.cls.get_overload("addDataToInt")
         instance = self.inst
         for i in range(NNN):
-            #inst.invoke(cls.get_overload("addDataToDouble"), float(i))
-            #inst.invoke(cls.get_overload("addDataToInt"), i)
-            instance.invoke(addDataToInt, i)
+            addDataToInt.call(instance, None, i)
         return i
 
 class CppyyPythonBench1(object):
@@ -89,6 +95,12 @@
         print run_bench(cintex_bench1)
         sys.exit(0)
 
+    # special case for PyCintex (run under python, not pypy-c)
+    if '--pyroot' in sys.argv:
+        pyroot_bench1 = PyROOTBench1()
+        print run_bench(pyroot_bench1)
+        sys.exit(0)
+
     # get C++ reference point
     if not os.path.exists("bench1.exe") or\
             os.stat("bench1.exe").st_mtime < os.stat("bench1.cxx").st_mtime:
@@ -111,3 +123,5 @@
     print_bench("cppyy python", run_bench(python_bench1))
     stat, t_cintex = commands.getstatusoutput("python bench1.py --pycintex")
     print_bench("pycintex    ", float(t_cintex))
+    #stat, t_pyroot = commands.getstatusoutput("python bench1.py --pyroot")
+    #print_bench("pyroot      ", float(t_pyroot))


More information about the pypy-commit mailing list