CMS 3D CMS Logo

Functions | Variables
cmsScimarkParser Namespace Reference

Functions

def get_max (data, index=1)
 
def get_min (data, index=1)
 
def manipulate_log (outdir, logfile_name, secsperbin)
 

Variables

 args
 
 default
 
 dest
 
 help
 
 options
 
 parser
 
 startevt
 
 usage
 

Function Documentation

◆ get_max()

def cmsScimarkParser.get_max (   data,
  index = 1 
)

Definition at line 5 of file cmsScimarkParser.py.

Referenced by manipulate_log().

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

◆ get_min()

def cmsScimarkParser.get_min (   data,
  index = 1 
)

Definition at line 13 of file cmsScimarkParser.py.

Referenced by manipulate_log().

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

◆ manipulate_log()

def cmsScimarkParser.manipulate_log (   outdir,
  logfile_name,
  secsperbin 
)

Definition at line 21 of file cmsScimarkParser.py.

References dqmMemoryStats.float, get_max(), get_min(), createfilelist.int, and print().

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

Variable Documentation

◆ args

cmsScimarkParser.args

Definition at line 191 of file cmsScimarkParser.py.

◆ default

cmsScimarkParser.default

Definition at line 178 of file cmsScimarkParser.py.

◆ dest

cmsScimarkParser.dest

Definition at line 179 of file cmsScimarkParser.py.

◆ help

cmsScimarkParser.help

Definition at line 177 of file cmsScimarkParser.py.

◆ options

cmsScimarkParser.options

Definition at line 191 of file cmsScimarkParser.py.

◆ parser

cmsScimarkParser.parser

Definition at line 175 of file cmsScimarkParser.py.

◆ startevt

cmsScimarkParser.startevt

Definition at line 203 of file cmsScimarkParser.py.

◆ usage

cmsScimarkParser.usage

Definition at line 174 of file cmsScimarkParser.py.