Author: Wim Lavrijsen <wlavrij...@lbl.gov> Branch: reflex-support Changeset: r54164:ea7e2c6e0d5b Date: 2012-03-30 16:52 -0700 http://bitbucket.org/pypy/pypy/changeset/ea7e2c6e0d5b/
Log: easier use for testing the various executables diff --git a/pypy/module/cppyy/bench/bench02.h b/pypy/module/cppyy/bench/bench02.h --- a/pypy/module/cppyy/bench/bench02.h +++ b/pypy/module/cppyy/bench/bench02.h @@ -7,12 +7,15 @@ #include "TH1F.h" #include "TH2F.h" #include "TRandom.h" +#include "TRandom3.h" #include "TROOT.h" #include "TApplication.h" +#include "TSystem.h" #include "TArchiveFile.h" #include "TBasket.h" +#include "TBenchmark.h" #include "TBox.h" #include "TBranchRef.h" #include "TBrowser.h" @@ -67,10 +70,3 @@ void report(); void close_file(TFile* f); }; - -/* -gROOT = cppyy.gbl.gROOT -gBenchmark = cppyy.gbl.gBenchmark -gRandom = cppyy.gbl.gRandom -gSystem = cppyy.gbl.gSystem -*/ diff --git a/pypy/module/cppyy/bench/bench02.xml b/pypy/module/cppyy/bench/bench02.xml --- a/pypy/module/cppyy/bench/bench02.xml +++ b/pypy/module/cppyy/bench/bench02.xml @@ -7,6 +7,11 @@ <class pattern="ROOT::T[A-Z]*" /> <class pattern="ROOT::Fit::*" /> + <!-- ROOT globals --> + <variable name="gROOT" /> + <variable name="gSystem" /> + <variable name="gRandom" /> + <!-- STL classes actually used --> <class name="std::string" /> <class name="std::ostream" /> diff --git a/pypy/module/cppyy/bench/hsimple.py b/pypy/module/cppyy/bench/hsimple.py --- a/pypy/module/cppyy/bench/hsimple.py +++ b/pypy/module/cppyy/bench/hsimple.py @@ -10,9 +10,15 @@ #*-* #*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* +_reflex = True # to keep things equal, set to False for full macro + try: import cppyy, random + if not hasattr(cppyy.gbl, 'gROOT'): + cppyy.load_reflection_info('bench02Dict_reflex.so') + _reflex = True + TCanvas = cppyy.gbl.TCanvas TFile = cppyy.gbl.TFile TProfile = cppyy.gbl.TProfile @@ -30,22 +36,27 @@ from ROOT import gROOT, gBenchmark, gSystem import random +if _reflex: + gROOT.SetBatch(True) + # Create a new ROOT binary machine independent file. # Note that this file may contain any kind of ROOT objects, histograms, # pictures, graphics objects, detector geometries, tracks, events, etc.. # This file is now becoming the current directory. -hfile = gROOT.FindObject('hsimple.root') -if hfile: - hfile.Close() -hfile = TFile('hsimple.root', 'RECREATE', 'Demo ROOT file with histograms' ) +if not _reflex: + hfile = gROOT.FindObject('hsimple.root') + if hfile: + hfile.Close() + hfile = TFile('hsimple.root', 'RECREATE', 'Demo ROOT file with histograms' ) # Create some histograms, a profile histogram and an ntuple hpx = TH1F('hpx', 'This is the px distribution', 100, -4, 4) hpx.SetFillColor(48) hpxpy = TH2F('hpxpy', 'py vs px', 40, -4, 4, 40, -4, 4) hprof = TProfile('hprof', 'Profile of pz versus px', 100, -4, 4, 0, 20) -ntuple = TNtuple('ntuple', 'Demo ntuple', 'px:py:pz:random:i') +if not _reflex: + ntuple = TNtuple('ntuple', 'Demo ntuple', 'px:py:pz:random:i') gBenchmark.Start('hsimple') @@ -71,14 +82,15 @@ hpx.Fill(px) hpxpy.Fill(px, py) hprof.Fill(px, pz) - ntuple.Fill(px, py, pz, rnd, i) + if not _reflex: + ntuple.Fill(px, py, pz, rnd, i) # Update display every kUPDATE events if i and i%kUPDATE == 0: if i == kUPDATE: hpx.Draw() - c1.Modified() + c1.Modified(True) c1.Update() if gSystem.ProcessEvents(): # allow user interrupt @@ -88,9 +100,10 @@ # Save all objects in this file hpx.SetFillColor(0) -hfile.Write() +if not _reflex: + hfile.Write() hpx.SetFillColor(48) -c1.Modified() +c1.Modified(True) c1.Update() # Note that the file is automatically closed when application terminates _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit