CMS 3D CMS Logo

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.

00005                          :
00006     max_score=-1
00007     for el in data:
00008         sec=el[index]
00009         if max_score<sec:
00010             max_score=sec
00011     return max_score

def cmsScimarkParser::get_min (   data,
  index = 1 
)

Definition at line 12 of file cmsScimarkParser.py.

00013                          :
00014     min_score=1e20
00015     for el in data:
00016         sec=el[index]
00017         if min_score>sec:
00018             min_score=sec
00019     return min_score    
    
def cmsScimarkParser::manipulate_log (   outdir,
  logfile_name,
  secsperbin 
)

Definition at line 20 of file cmsScimarkParser.py.

00021                                                   :
00022 
00023     import time
00024     import sys
00025     import ROOT       
00026     
00027     # the fundamental structure: the key is the evt number the value is a list containing
00028     # Composite Score
00029     data=[]
00030     
00031     # open file and read it and fill the structure!
00032     logfile=open(logfile_name,'r')
00033     logfile_lines=logfile.readlines()
00034     if not logfile_lines:
00035         print "The logfile %s is empty! Exiting now."%logfile_name
00036         sys.exit()
00037     logfile.close()
00038 
00039     # we get the info we need!
00040     i=0
00041     bench_number=0;
00042     while i < len(logfile_lines):
00043         line=logfile_lines[i]
00044         #if 'TimeEvent>' in line:
00045         if 'Composite Score:' in line:
00046             line=line[:-1] #no \n!
00047             line_content_list=line.split()
00048             #event_number=int(line_content_list[1])
00049             #seconds=float(line_content_list[3])
00050             composite_score=float(line_content_list[2])
00051             #data.append((event_number,seconds))
00052             bench_number+=1
00053             data.append((bench_number,composite_score))
00054         i+=1
00055                                               
00056     # init Graph and histo
00057     
00058     # The Graphs 
00059     __argv=sys.argv # trick for a strange behaviour of the TApp..
00060     sys.argv=sys.argv[:1]
00061     ROOT.gROOT.SetStyle("Plain") # style paranoia
00062     sys.argv=__argv
00063     #Cannot use this option when the logfile includes ~2000
00064     #Composite Scores or more... PyRoot seg-faults.
00065     #Set ROOT in batch mode to avoid canvases popping up!
00066     #ROOT.gROOT.SetBatch(1)
00067 
00068     # Save in file
00069     rootfilename='%s/graphs.root' %outdir
00070     myfile=ROOT.TFile(rootfilename,'RECREATE')   
00071     
00072     
00073     # Set fancy limits
00074     min_val=get_min(data,1)
00075     max_val=get_max(data,1)
00076     interval=int(max_val-min_val)
00077     
00078     min_val=min_val-interval*0.2
00079     max_val=max_val+interval*0.2
00080     interval=int(max_val-min_val)
00081     
00082     nbins=int(interval/secsperbin)
00083     
00084     print 'Minval=',min_val,' maxval=',max_val, ' interval=',interval
00085     
00086     histo=ROOT.TH1F('Composite Score(Mflops)','Composite Score (Mflops)',nbins,min_val,max_val)
00087     histo.GetXaxis().SetTitle("Mflops")    
00088     
00089     npoints=len(data)   
00090     
00091     graph=ROOT.TGraph(npoints)
00092     graph.SetMarkerStyle(8)
00093     graph.SetMarkerSize(.7)
00094     graph.SetMarkerColor(1)
00095     graph.SetLineWidth(3)
00096     graph.SetLineColor(2)        
00097     graph.SetTitle('Composite Score')
00098     graph.SetName('Composite Score')    
00099     graph.GetXaxis().SetTitle("Benchmark sequential number")
00100     
00101     last_event=data[-1][0]
00102     print 'last event =',last_event
00103     graph.GetXaxis().SetLimits(0,last_event)
00104         
00105     graph.GetYaxis().SetTitleOffset(1.3)
00106     graph.GetYaxis().SetTitle("Mflops")
00107     graph.GetYaxis().SetRangeUser(min_val,max_val)
00108 
00109     
00110     
00111     # Fill them
00112     
00113     evt_counter=0
00114     for bench_number,composite_score in data:
00115         graph.SetPoint(evt_counter,bench_number,composite_score)
00116         histo.Fill(composite_score)
00117         evt_counter+=1
00118                 
00119     #A line which represents the average is drawn in the TGraph
00120     avg=histo.GetMean()
00121     avg_line=ROOT.TLine(1,avg,last_event,avg)
00122     avg_line.SetLineColor(4)
00123     avg_line.SetLineWidth(2)
00124         
00125     # draw and save!
00126     graph_canvas=ROOT.TCanvas('graph_canvas')
00127     graph_canvas.cd()
00128     graph.Draw("ALP")
00129     avg_line.Draw("Same")
00130     
00131     graph_canvas.Print("%s/graph.gif" %outdir,"gif")
00132     
00133     # write it on file
00134     graph.Write()
00135     graph_canvas.Write()    
00136 
00137     histo_canvas=ROOT.TCanvas('histo_canvas')
00138     histo_canvas.cd()
00139     histo.Draw('')
00140 
00141     histo_canvas.Print("%s/histo.gif" %outdir,"gif")
00142     
00143     # write it on file
00144     histo.Write()
00145     histo_canvas.Write() 
00146     
00147     myfile.Close()   
00148                     
00149     # The html page!------------------------------------------------------------------------------
00150     
00151     titlestring='<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
00152                                    %(os.environ['CMSSW_VERSION'],time.asctime())
00153         
00154     html_file_name='%s/%s.html' %(outdir,logfile_name[:-4])# a way to say the string until its last but 4th char
00155     html_file=open(html_file_name,'w')
00156     html_file.write('<html>\n<body>\n'+\
00157                     titlestring)
00158     html_file.write('<table>\n'+\
00159                     '<tr><td><img  src=graph.gif></img></td></tr>'+\
00160                     '<tr><td><img  src=histo.gif></img></td></tr>'+\
00161                     '</table>\n')
00162     html_file.write('\n</body>\n</html>')
00163     html_file.close()    
00164     
    

Variable Documentation

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.