CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
cmsScimarkParser Namespace Reference

Functions

def get_max
 
def get_min
 
def manipulate_log
 

Variables

string default = ''
 
string dest = 'profile'
 
string help = 'The profile to manipulate'
 
tuple parser = optparse.OptionParser(usage)
 
tuple startevt = float(options.startevt)
 
string usage = 'cmsScimarkParser.py <options>'
 

Function Documentation

def cmsScimarkParser.get_max (   data,
  index = 1 
)

Definition at line 5 of file cmsScimarkParser.py.

Referenced by manipulate_log().

5 
6 def get_max(data,index=1):
7  max_score=-1
8  for el in data:
9  sec=el[index]
10  if max_score<sec:
11  max_score=sec
12  return max_score
def cmsScimarkParser.get_min (   data,
  index = 1 
)

Definition at line 13 of file cmsScimarkParser.py.

Referenced by manipulate_log().

13 
14 def get_min(data,index=1):
15  min_score=1e20
16  for el in data:
17  sec=el[index]
18  if min_score>sec:
19  min_score=sec
20  return min_score
def cmsScimarkParser.manipulate_log (   outdir,
  logfile_name,
  secsperbin 
)

Definition at line 21 of file cmsScimarkParser.py.

References get_max(), get_min(), and print().

21 
22 def manipulate_log(outdir,logfile_name,secsperbin):
23 
24  import time
25  import sys
26  import ROOT
27 
28  # the fundamental structure: the key is the evt number the value is a list containing
29  # Composite Score
30  data=[]
31 
32  # open file and read it and fill the structure!
33  logfile=open(logfile_name,'r')
34  logfile_lines=logfile.readlines()
35  if not logfile_lines:
36  print("The logfile %s is empty! Exiting now."%logfile_name)
37  sys.exit()
38  logfile.close()
39 
40  # we get the info we need!
41  i=0
42  bench_number=0;
43  while i < len(logfile_lines):
44  line=logfile_lines[i]
45  #if 'TimeEvent>' in line:
46  if 'Composite Score:' in line:
47  line=line[:-1] #no \n!
48  line_content_list=line.split()
49  #event_number=int(line_content_list[1])
50  #seconds=float(line_content_list[3])
51  composite_score=float(line_content_list[2])
52  #data.append((event_number,seconds))
53  bench_number+=1
54  data.append((bench_number,composite_score))
55  i+=1
56 
57  # init Graph and histo
58 
59  # The Graphs
60  __argv=sys.argv # trick for a strange behaviour of the TApp..
61  sys.argv=sys.argv[:1]
62  ROOT.gROOT.SetStyle("Plain") # style paranoia
63  sys.argv=__argv
64  #Cannot use this option when the logfile includes ~2000
65  #Composite Scores or more... PyRoot seg-faults.
66  #Set ROOT in batch mode to avoid canvases popping up!
67  #ROOT.gROOT.SetBatch(1)
68 
69  # Save in file
70  rootfilename='%s/graphs.root' %outdir
71  myfile=ROOT.TFile(rootfilename,'RECREATE')
72 
73 
74  # Set fancy limits
75  min_val=get_min(data,1)
76  max_val=get_max(data,1)
77  interval=int(max_val-min_val)
78 
79  min_val=min_val-interval*0.2
80  max_val=max_val+interval*0.2
81  interval=int(max_val-min_val)
82 
83  nbins=int(interval/secsperbin)
84 
85  print('Minval=',min_val,' maxval=',max_val, ' interval=',interval)
86 
87  histo=ROOT.TH1F('Composite Score(Mflops)','Composite Score (Mflops)',nbins,min_val,max_val)
88  histo.GetXaxis().SetTitle("Mflops")
89 
90  npoints=len(data)
91 
92  graph=ROOT.TGraph(npoints)
93  graph.SetMarkerStyle(8)
94  graph.SetMarkerSize(.7)
95  graph.SetMarkerColor(1)
96  graph.SetLineWidth(3)
97  graph.SetLineColor(2)
98  graph.SetTitle('Composite Score')
99  graph.SetName('Composite Score')
100  graph.GetXaxis().SetTitle("Benchmark sequential number")
101 
102  last_event=data[-1][0]
103  print('last event =',last_event)
104  graph.GetXaxis().SetLimits(0,last_event)
105 
106  graph.GetYaxis().SetTitleOffset(1.3)
107  graph.GetYaxis().SetTitle("Mflops")
108  graph.GetYaxis().SetRangeUser(min_val,max_val)
109 
110 
111 
112  # Fill them
113 
114  evt_counter=0
115  for bench_number,composite_score in data:
116  graph.SetPoint(evt_counter,bench_number,composite_score)
117  histo.Fill(composite_score)
118  evt_counter+=1
119 
120  #A line which represents the average is drawn in the TGraph
121  avg=histo.GetMean()
122  avg_line=ROOT.TLine(1,avg,last_event,avg)
123  avg_line.SetLineColor(4)
124  avg_line.SetLineWidth(2)
125 
126  # draw and save!
127  graph_canvas=ROOT.TCanvas('graph_canvas')
128  graph_canvas.cd()
129  graph.Draw("ALP")
130  avg_line.Draw("Same")
131 
132  graph_canvas.Print("%s/graph.png" %outdir,"png")
133 
134  # write it on file
135  graph.Write()
136  graph_canvas.Write()
137 
138  histo_canvas=ROOT.TCanvas('histo_canvas')
139  histo_canvas.cd()
140  histo.Draw('')
141 
142  histo_canvas.Print("%s/histo.png" %outdir,"png")
143 
144  # write it on file
145  histo.Write()
146  histo_canvas.Write()
147 
148  myfile.Close()
149 
150  # The html page!------------------------------------------------------------------------------
151 
152  titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
153  %(os.environ['CMSSW_VERSION'],time.asctime())
154 
155  html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])# a way to say the string until its last but 4th char
156  html_file=open(html_file_name,'w')
157  html_file.write('<html>\n<body>\n'+\
158  titlestring)
159  html_file.write('<table>\n'+\
160  '<tr><td><img src=graph.png></img></td></tr>'+\
161  '<tr><td><img src=histo.png></img></td></tr>'+\
162  '</table>\n')
163  html_file.write('\n</body>\n</html>')
164  html_file.close()
165 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Variable Documentation

string cmsScimarkParser.default = ''

Definition at line 178 of file cmsScimarkParser.py.

string cmsScimarkParser.dest = 'profile'

Definition at line 179 of file cmsScimarkParser.py.

string cmsScimarkParser.help = 'The profile to manipulate'

Definition at line 177 of file cmsScimarkParser.py.

tuple cmsScimarkParser.parser = optparse.OptionParser(usage)

Definition at line 175 of file cmsScimarkParser.py.

tuple cmsScimarkParser.startevt = float(options.startevt)

Definition at line 203 of file cmsScimarkParser.py.

string cmsScimarkParser.usage = 'cmsScimarkParser.py <options>'

Definition at line 174 of file cmsScimarkParser.py.