Logo ROOT   6.07/09
Reference Guide
Namespaces
benchmarks.py File Reference

Namespaces

 benchmarks
 

Detailed Description

Run benchmarks macros.

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

Definition in file benchmarks.py.