ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
benchmarks.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ## Run benchmarks macros.
4 ##
5 ## \macro_image
6 ## \macro_code
7 ##
8 ## \author Wim Lavrijsen
9 
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  execfile( os.path.join( macrodir, macro ), 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  try:
49  # convenience, allowing to run this file from a different directory
50  macrodir = os.path.dirname( os.path.join( os.getcwd(), __file__ ) )
51  except NameError:
52  macrodir = '' # in case of p2.2
53 
54  # window for keeping track of bench marks that are run
55  bench = ROOT.TCanvas( 'bench','Benchmarks Summary', -1000, 50, 200, 500 )
56  summary = ROOT.TPaveText( 0, 0, 1, 1 )
57  summary.SetTextAlign( 12 )
58  summary.SetTextSize( 0.1 )
59  summary.Draw()
60 
61  for m in macros:
62  summary.AddText( ' ** %s' % m )
63 
64  # run benchmarks, the last one (rootmarks.py) results in a report
65  for m in macros:
66  bexec( macrodir, m, bench )
void bexec(TString &dir, const char *macro)
Definition: benchmarks.C:3