Logo ROOT   6.08/07
Reference Guide
benchmarks.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ## Run benchmarks macros.
4 ##
5 ## \macro_code
6 ##
7 ## \author Wim Lavrijsen
8 
9 from __future__ import print_function
10 import os, sys
11 import ROOT
12 
13 ROOT.SetSignalPolicy( ROOT.kSignalFast )
14 
15 ## macro files
16 macros = [
17  'framework.py', 'hsimple.py', 'hsum.py', 'formula1.py',
18  'fillrandom.py','fit1.py', 'h1draw.py', 'graph.py',
19  'gerrors.py', 'tornado.py', 'surfaces.py', 'zdemo.py',
20  'geometry.py', 'na49view.py', 'file.py',
21  'ntuple1.py', 'rootmarks.py' ]
22 
23 ## note: this function is defined in tutorials/rootlogon.C
24 def bexec( dir, macro, bench ):
25  if ROOT.gROOT.IsBatch():
26  print('Processing benchmark: %s\n' % macro)
27 
28  summary = bench.GetPrimitive( 'TPave' )
29  tmacro = summary.GetLineWith( macro )
30  if tmacro:
31  tmacro.SetTextColor( 4 )
32  bench.Modified()
33  bench.Update()
34 
35  exec( open(os.path.join( macrodir, macro )).read(), sys.modules[ __name__ ].__dict__ )
36 
37  summary2 = bench.GetPrimitive( 'TPave' )
38  tmacro2 = summary2.GetLineWith( macro )
39  if tmacro2:
40  tmacro2.SetTextColor( 2 )
41  bench.Modified()
42  bench.Update()
43 
44 
45 ## --------------------------------------------------------------------------
46 if __name__ == '__main__':
47 
48  macrodir = os.path.join(ROOT.gROOT.GetTutorialsDir(), 'pyroot')
49 
50  # window for keeping track of bench marks that are run
51  bench = ROOT.TCanvas( 'bench','Benchmarks Summary', -1000, 50, 200, 500 )
52  summary = ROOT.TPaveText( 0, 0, 1, 1 )
53  summary.SetTextAlign( 12 )
54  summary.SetTextSize( 0.1 )
55  summary.Draw()
56 
57  for m in macros:
58  summary.AddText( ' ** %s' % m )
59 
60  # run benchmarks, the last one (rootmarks.py) results in a report
61  for m in macros:
62  bexec( macrodir, m, bench )
double read(const std::string &file_name)
reading