CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 4 of file cmsScimarkParser.py.

Referenced by manipulate_log().

4 
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
def cmsScimarkParser.get_min (   data,
  index = 1 
)

Definition at line 12 of file cmsScimarkParser.py.

Referenced by manipulate_log().

12 
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
def cmsScimarkParser.manipulate_log (   outdir,
  logfile_name,
  secsperbin 
)

Definition at line 20 of file cmsScimarkParser.py.

References get_max(), and get_min().

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

Variable Documentation

string cmsScimarkParser.default = ''

Definition at line 177 of file cmsScimarkParser.py.

string cmsScimarkParser.dest = 'profile'

Definition at line 178 of file cmsScimarkParser.py.

string cmsScimarkParser.help = 'The profile to manipulate'

Definition at line 176 of file cmsScimarkParser.py.

tuple cmsScimarkParser.parser = optparse.OptionParser(usage)

Definition at line 174 of file cmsScimarkParser.py.

tuple cmsScimarkParser.startevt = float(options.startevt)

Definition at line 202 of file cmsScimarkParser.py.

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

Definition at line 173 of file cmsScimarkParser.py.