CMS 3D CMS Logo

Classes | Functions | Variables
cmsPerfRegress Namespace Reference

Classes

class  EdmSizeErr
 
class  Error
 
class  PerfReportErr
 
class  SimpMemParseErr
 
class  TimingParseErr
 

Functions

def _main ()
 
def cmpCallgrindReport (outdir, file1, file2)
 
def cmpEdmSizeReport (outdir, file1, file2)
 
def cmpIgProfReport (outdir, file1, file2, IgProfMemOpt="")
 
def cmpSimpMemReport (rootfilename, outdir, oldLogfile, newLogfile, startevt, batch=True, candle="", prevrev="")
 
def cmpTimingReport (rootfilename, outdir, oldLogfile, newLogfile, secsperbin, batch=True, prevrev="")
 
def createROOT (outdir, filename)
 Create the root file to save the graphs in. More...
 
def createSimplMemGraphs (data, npoints, graph_num, legs, prevrev="")
 Create simple memory check graphs. More...
 
def drawChanges (graph, chgleg)
 Draw data differences (comparison between two data sets or releases) on a separate canvas. More...
 
def drawGraphs (graph1, graph2, avg1, avg2, leg)
 Draw superimposed graphs on a separate canvas. More...
 
def drawHistos (histo_stack, hstleg)
 Draw superimposed histograms on a separate canvas. More...
 
def drawMemChangeGraphs (graph, leg, memtype, stepname)
 Draw the comparison graphs of two memory graphs. More...
 
def drawMemGraphs (graph1, graph2, min_val, max_val, last_event, leg, memtype, stepname)
 Draw two memory graphs superimposed on one another. More...
 
def get_max (data, index=1)
 Get max value in data set. More...
 
def get_min (data, index=1)
 Get min value in data set. More...
 
def getLimits (data, secsperbin)
 Get limits to plot the graph. More...
 
def getMeanLines (avg, last_event, graph_num)
 Plot the mean line on a graph. More...
 
def getMemDiff (data1, data2, npoints, last_event, orig_max_val, stepname, rss=False)
 Produce the difference of two memory data sets. More...
 
def getMemOrigScale (fst_min, snd_min, fst_max, snd_max)
 
def getNpoints (data)
 
def getParameters ()
 
def getSimpleMemLogData (logfile_name, startevt, candle)
 Parse memory check data from log file. More...
 
def getTimingDiff (data1, data2, npoints, last_event, orig_max_val)
 Get the difference in timing data (for comparison of two releases) More...
 
def getTimingLogData (logfile_name)
 Parse timing data from log file. More...
 
def getTwoGraphLimits (last_event1, max_val1, last_event2, max_val2, min_val1=-1, min_val2=-1)
 Get limits for two graphs that will be superimposed upon one another. More...
 
def newGraphAndHisto (histoleg, leg, npoints, nbins, min_val, max_val, data, graph_num, prevrev="")
 Create a new timing graph and histogram. More...
 
def perfreport (perftype, file1, file2, outdir, IgProfMemopt="")
 
def rmtree (path)
 
def setBatch ()
 Setup PyRoot as a batch run. More...
 
def setupSuperimpose (graph1, graph2, last_event, max_val, reporttype=0, title="")
 Setup graph information for one graph (no need to it on both if they are superimposed) More...
 
def ungzip (inf, outh)
 
def ungzip2 (inf, out)
 

Variables

 _cmsver
 
 values_set
 

Function Documentation

def cmsPerfRegress._main ( )
private

Definition at line 1166 of file cmsPerfRegress.py.

References cmpCallgrindReport(), cmpEdmSizeReport(), cmpIgProfReport(), cmpSimpMemReport(), cmpTimingReport(), getParameters(), and edm.print().

1166 def _main():
1167  outdir = os.getcwd()
1168 
1169  (file1,file2,secsperbin,reporttype,IgProfMemOptions) = getParameters()
1170 
1171  try:
1172  if reporttype == "timing":
1173  rootfilename = "timingrep-regression.root"
1174  cmpTimingReport(rootfilename ,outdir,file1,file2,secsperbin,True)
1175  elif reporttype == "simplememory":
1176  rootfilename = "simpmem-regression.root"
1177  cmpSimpMemReport(rootfilename,outdir,file1,file2,secsperbin,True)
1178  elif reporttype == "edmsize":
1179  cmpEdmSizeReport(outdir,file1,file2)
1180  elif reporttype == "callgrind":
1181  cmpCallgrindReport(outdir,file1,file2)
1182  elif reporttype == "igprof":
1183  cmpIgProfReport(outdir,file1,file2,IgProfMemOptions)
1184  except TimingParseErr as detail:
1185  print("WARNING: Could not parse data from Timing report file %s; not performing regression" % detail.message)
1186  except SimpMemParseErr as detail:
1187  print("WARNING: Could not parse data from Memory report file %s; not performing regression" % detail.message)
1188  except PerfReportErr as detail:
1189  print("WARNING: Could not parse data from Edm file %s; not performing regression" % detail.message)
1190  except IOError as detail:
1191  print(detail)
1192  except OSError as detail:
1193  print(detail)
1194 
def cmpEdmSizeReport(outdir, file1, file2)
def cmpTimingReport(rootfilename, outdir, oldLogfile, newLogfile, secsperbin, batch=True, prevrev="")
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmpCallgrindReport(outdir, file1, file2)
def cmpSimpMemReport(rootfilename, outdir, oldLogfile, newLogfile, startevt, batch=True, candle="", prevrev="")
def cmpIgProfReport(outdir, file1, file2, IgProfMemOpt="")
def cmsPerfRegress.cmpCallgrindReport (   outdir,
  file1,
  file2 
)

Definition at line 1163 of file cmsPerfRegress.py.

References perfreport().

Referenced by _main().

1163 def cmpCallgrindReport(outdir,file1,file2):
1164  perfreport(2,file1,file2,outdir)
1165 
def perfreport(perftype, file1, file2, outdir, IgProfMemopt="")
def cmpCallgrindReport(outdir, file1, file2)
def cmsPerfRegress.cmpEdmSizeReport (   outdir,
  file1,
  file2 
)

Definition at line 1117 of file cmsPerfRegress.py.

References perfreport().

Referenced by _main().

1117 def cmpEdmSizeReport(outdir,file1,file2):
1118  perfreport(0,file1,file2,outdir)
1119 
def cmpEdmSizeReport(outdir, file1, file2)
def perfreport(perftype, file1, file2, outdir, IgProfMemopt="")
def cmsPerfRegress.cmpIgProfReport (   outdir,
  file1,
  file2,
  IgProfMemOpt = "" 
)

Definition at line 1132 of file cmsPerfRegress.py.

References perfreport(), str, and ungzip2().

Referenced by _main().

1132 def cmpIgProfReport(outdir,file1,file2,IgProfMemOpt=""):
1133  (tfile1, tfile2) = ("", "")
1134  try:
1135  # don't make temp files in /tmp because it's never bloody big enough
1136  (th1, tfile1) = tmp.mkstemp(prefix=os.path.join(outdir,"igprofRegressRep."))
1137  (th2, tfile2) = tmp.mkstemp(prefix=os.path.join(outdir,"igprofRegressRep."))
1138  os.close(th1)
1139  os.close(th2)
1140  os.remove(tfile1)
1141  os.remove(tfile2)
1142  ungzip2(file1,tfile1)
1143  ungzip2(file2,tfile2)
1144 
1145  perfreport(1,tfile1,tfile2,outdir,IgProfMemOpt)
1146 
1147  os.remove(tfile1)
1148  os.remove(tfile2)
1149  except OSError as detail:
1150  raise PerfReportErr("WARNING: The OS returned the following error when comparing %s and %s\n%s" % (file1,file2,str(detail)))
1151  if os.path.exists(tfile1):
1152  os.remove(tfile1)
1153  if os.path.exists(tfile2):
1154  os.remove(tfile2)
1155  except IOError as detail:
1156  raise PerfReportErr("IOError: When comparing %s and %s using temporary files %s and %s. Error message:\n%s" % (file1,file2,tfile1,tfile2,str(detail)))
1157  if os.path.exists(tfile1):
1158  os.remove(tfile1)
1159  if os.path.exists(tfile2):
1160  os.remove(tfile2)
1161 
1162 
def perfreport(perftype, file1, file2, outdir, IgProfMemopt="")
def cmpIgProfReport(outdir, file1, file2, IgProfMemOpt="")
def ungzip2(inf, out)
#define str(s)
def cmsPerfRegress.cmpSimpMemReport (   rootfilename,
  outdir,
  oldLogfile,
  newLogfile,
  startevt,
  batch = True,
  candle = "",
  prevrev = "" 
)

Definition at line 730 of file cmsPerfRegress.py.

References createROOT(), createSimplMemGraphs(), drawMemChangeGraphs(), drawMemGraphs(), getMemDiff(), getMemOrigScale(), getSimpleMemLogData(), getTwoGraphLimits(), genParticles_cff.map, edm.print(), setBatch(), and setupSuperimpose().

Referenced by _main().

730 def cmpSimpMemReport(rootfilename,outdir,oldLogfile,newLogfile,startevt,batch=True,candle="",prevrev=""):
731  if batch:
732  setBatch()
733  # the fundamental structure: the key is the evt number the value is a list containing
734  # VSIZE deltaVSIZE RSS deltaRSS
735  print("#####LOGFILES in cmsPErfRegress:")
736  print(oldLogfile)
737  print(newLogfile)
738  try:
739  info1 = getSimpleMemLogData(oldLogfile,startevt, candle)
740  if len(info1) == 0:
741  raise IndexError
742  except IndexError:
743  raise SimpMemParseErr(oldLogfile)
744  except IOError:
745  raise SimpMemParseErr(oldLogfile)
746 
747  try:
748  info2 = getSimpleMemLogData(newLogfile,startevt, candle)
749  if len(info2) == 0:
750  raise IndexError
751  except IndexError:
752  raise SimpMemParseErr(newLogfile)
753  except IOError:
754  raise SimpMemParseErr(newLogfile)
755  #print "DDDDD info1 %s"%info1 #Format is of the type:[('GEN,SIM', [(1, {'delta_vsize': 0.0, 'delta_rss': 0.0, 'vsize': 648.42600000000004, 'rss': 426.33199999999999}), (2,{...
756  #print "DDDDD info2 %s"%info2
757  canvases = []
758  # skim the second entry when the event number is the same BUG!!!!!!!
759  # i take elements in couples!
760 
761  candreg = re.compile("(.*)(?:\.log)")
762  vsize_canvas = None
763  rss_canvas = None
764  i = 0
765  firstRoot = True
766  newrootfile = None
767  #The following whileis confusing and not necessary info1 and info2 are supposed to only contain one set of simplememorycheck numbers
768  #in a tuple as seen above ('GEN,SIM',[(event_number,{'delta_vsize': 0.0, etc
769  #The data structure is questionable... but it is a remnant of past format of the log files I guess.
770  #while ( i < len(info1) and i < len(info2)):
771  #curinfo1 = info1[i]
772  #curinfo2 = info2[i]
773  (stepname1, data1) = info1[0]
774  (stepname2, data2) = info2[0]
775 
776  #Again this is not necessary anymore...
777  #if not stepname1 == stepname2:
778  #print "WARNING: Could not compare %s step and %s step because they are not the same step" % (stepname1, stepname2)
779  # print " Searching for next occurence"
780  # x = 1
781  # if not (i + 1) > len(info1):
782  # found = False
783  # for info in info1[i + 1:]:
784  # (stepname,trash) = info
785  # if stepname == stepname2:
786  # i += x
787  #print " Next occurence found, skipping in-between steps"
788  # assert i < len(info1)
789  # found = True
790  # break
791  # x += 1
792  # if found:
793  # continue
794  # print " No more occurences of this step, continuing"
795  # i += 1
796  # continue
797 
798  #Not sure what this is for!
799  #OK it was due to the bug of duplicated info in getSimpleMemLogData parsing!
800  #No need!
801  #(data1,npoints1) = getNpoints(data1)
802  #(data2,npoints2) = getNpoints(data2)
803  npoints1=len(data1)
804  npoints2=len(data2)
805 
806  legs = []
807  leg = ROOT.TLegend(0.6,0.99,0.89,0.8)
808  legs.append(leg)
809  leg = ROOT.TLegend(0.6,0.99,0.89,0.8)
810  legs.append(leg)
811 
812  try:
813  if len(data1) == 0:
814  raise IndexError
815  (vsize_graph1,
816  vsize_lstevt1,
817  vsize_peak1,
818  vsize_minim1,
819  rss_graph1,
820  rss_lstevt1,
821  rss_peak1,
822  rss_minim1) = createSimplMemGraphs(data1,npoints1,0,legs,prevrev=prevrev)
823  #candFilename = CandFname[candle]
824  #outputdir = "%s_%s_SimpleMemReport" % (candFilename,stepname1)
825  #outputdir = os.path.join(outdir,outputdir)
826  #print "Graph1"
827  #vsize_graph1.Print()
828  except IndexError:
829  raise SimpMemParseErr(oldLogfile)
830 
831  try:
832  if len(data2) == 0:
833  raise IndexError
834  (vsize_graph2,
835  vsize_lstevt2,
836  vsize_peak2,
837  vsize_minim2,
838  rss_graph2,
839  rss_lstevt2,
840  rss_peak2,
841  rss_minim2) = createSimplMemGraphs(data2,npoints2,1,legs,prevrev=prevrev)
842  #candFilename = CandFname[candle]
843  #outputdir = "%s_%s_SimpleMemReport" % (candFilename,stepname1)
844  #outputdir = os.path.join(outdir,outputdir)
845  #print "Graph2"
846  #vsize_graph2.Print()# os.path.join(outputdir,"vsize_graph2.png"))
847  except IndexError:
848  raise SimpMemParseErr(newLogfile)
849 
850 
851  (vsize_lstevt, vsize_max_val, vsize_min_val) = getTwoGraphLimits(vsize_lstevt1, vsize_peak1, vsize_lstevt2, vsize_peak2, vsize_minim1, vsize_minim2)
852  (rss_lstevt , rss_max_val , rss_min_val) = getTwoGraphLimits(rss_lstevt1 , rss_peak1, rss_lstevt2 , rss_peak2, rss_minim1, rss_minim2)
853 
854  (vsize_min,vsize_max) = getMemOrigScale(vsize_minim1,vsize_minim2,vsize_peak1,vsize_peak2)
855  (rss_min ,rss_max ) = getMemOrigScale(rss_minim1,rss_minim2,rss_peak1,rss_peak2)
856 
857  setupSuperimpose(vsize_graph1,
858  vsize_graph2,
859  vsize_lstevt,
860  0,
861  reporttype = 1,
862  title = "%s_vsize" % stepname1)
863  setupSuperimpose(rss_graph1 ,
864  rss_graph2 ,
865  rss_lstevt ,
866  0,
867  reporttype = 1,
868  title = "%s_rss" % stepname2)
869 
870  (vsizePerfDiffgraph, vsizeleg) = getMemDiff(data1,data2,npoints2,vsize_lstevt, (vsize_max - vsize_min), stepname1, rss=False)
871  (rssPerfDiffgraph, rssleg) = getMemDiff(data1,data2,npoints2,rss_lstevt , (rss_max - rss_min) , stepname1, rss=True )
872 
873  vsize_canvas = drawMemGraphs(vsize_graph1, vsize_graph2, vsize_min_val, vsize_max_val, vsize_lstevt, legs[0], "vsize", stepname1)
874  rss_canvas = drawMemGraphs(rss_graph1 , rss_graph2 , rss_min_val, rss_max_val, rss_lstevt, legs[1], "rss" , stepname1)
875  vsize_change_canvas = drawMemChangeGraphs(vsizePerfDiffgraph, vsizeleg, "vsize", stepname1)
876  rss_change_canvas = drawMemChangeGraphs(rssPerfDiffgraph , rssleg , "rss" , stepname1)
877 
878  if batch:
879 
880 
881  logcandle = ""
882  candname = ""
883  found = candreg.search(os.path.basename(newLogfile))
884 
885  if found:
886  logcandle = found.groups()[0]
887 
888  if candle in CandFname:
889  candFilename = CandFname[candle]
890  elif logcandle in CandFname:
891  candFilename = CandFname[logcandle]
892  else:
893  print("%s is an unknown candle!"%candle)
894  candFilename = "Unknown-candle"
895 
896  outputdir = "%s_%s_SimpleMemReport" % (candFilename,stepname1)
897  outputdir = os.path.join(outdir,outputdir)
898 
899  if not os.path.exists(outputdir):
900  os.mkdir(outputdir)
901 
902  #print the graphs as files :)
903 
904  newrootfile = createROOT(outputdir,rootfilename)
905 
906  vsize_canvas.Print( os.path.join(outputdir,"vsize_graphs.png"), "png")
907  rss_canvas.Print( os.path.join(outputdir,"rss_graphs.png" ), "png")
908  vsize_change_canvas.Print(os.path.join(outputdir,"vsize_change.png"), "png")
909  rss_change_canvas.Print( os.path.join(outputdir,"rss_change.png" ), "png")
910  # write it on file
911  map(lambda x: x.Write(), [vsize_graph1,vsize_graph2, rss_graph1, rss_graph2, vsizePerfDiffgraph, rssPerfDiffgraph])
912  map(lambda x: x.Write(), [vsize_canvas,rss_canvas,vsize_change_canvas,rss_change_canvas])
913  newrootfile.Close()
914  else:
915  # we have to do this if we are running the application standalone
916  # For some reason it will not draw some graphs at all if there is more than
917  # one step.
918  # If we wait between iterations of this loop the graphs will be drawn correctly.
919  # Perhaps a graphics buffer problem with ROOT?
920  # Perhaps a garbage collection problem in python? (Doubt it)
921  canvases.append(rss_canvas)
922  canvases.append(vsize_canvas)
923  canvases.append(vsize_change_canvas)
924  canvases.append(rss_change_canvas)
925  time.sleep(5.0)
926 
927  #Eliminated the while loop!
928  #i += 1
929 
930  #
931  # Create a one dimensional function and draw it
932  #
933 
934  if batch:
935  pass
936  else:
937  if len(canvases) > 0:
938  while reduce(lambda x,y: x or y ,canvases):
939  time.sleep(2.5)
940  return 0
941 
942 
def createSimplMemGraphs(data, npoints, graph_num, legs, prevrev="")
Create simple memory check graphs.
def getMemOrigScale(fst_min, snd_min, fst_max, snd_max)
def getSimpleMemLogData(logfile_name, startevt, candle)
Parse memory check data from log file.
def getMemDiff(data1, data2, npoints, last_event, orig_max_val, stepname, rss=False)
Produce the difference of two memory data sets.
def setBatch()
Setup PyRoot as a batch run.
def drawMemGraphs(graph1, graph2, min_val, max_val, last_event, leg, memtype, stepname)
Draw two memory graphs superimposed on one another.
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmpSimpMemReport(rootfilename, outdir, oldLogfile, newLogfile, startevt, batch=True, candle="", prevrev="")
def createROOT(outdir, filename)
Create the root file to save the graphs in.
def getTwoGraphLimits(last_event1, max_val1, last_event2, max_val2, min_val1=-1, min_val2=-1)
Get limits for two graphs that will be superimposed upon one another.
def drawMemChangeGraphs(graph, leg, memtype, stepname)
Draw the comparison graphs of two memory graphs.
def setupSuperimpose(graph1, graph2, last_event, max_val, reporttype=0, title="")
Setup graph information for one graph (no need to it on both if they are superimposed) ...
def cmsPerfRegress.cmpTimingReport (   rootfilename,
  outdir,
  oldLogfile,
  newLogfile,
  secsperbin,
  batch = True,
  prevrev = "" 
)

Definition at line 943 of file cmsPerfRegress.py.

References mps_check.array, createROOT(), drawChanges(), drawGraphs(), drawHistos(), getLimits(), getMeanLines(), getTimingDiff(), getTimingLogData(), getTwoGraphLimits(), genParticles_cff.map, newGraphAndHisto(), setBatch(), and setupSuperimpose().

Referenced by _main().

943 def cmpTimingReport(rootfilename,outdir,oldLogfile,newLogfile,secsperbin,batch=True,prevrev=""):
944  if batch:
945  setBatch()
946 
947  data1 = getTimingLogData(oldLogfile)
948  data2 = getTimingLogData(newLogfile)
949 
950  try:
951  (min_val1,max_val1,nbins1,npoints1,last_event1) = getLimits(data1,secsperbin)
952  except IndexError as detail:
953  raise TimingParseErr(oldLogfile)
954 
955  try:
956  (min_val2,max_val2,nbins2,npoints2,last_event2) = getLimits(data2,secsperbin)
957  except IndexError as detail:
958  raise TimingParseErr(newLogfile)
959 
960  hsStack = ROOT.THStack("hsStack","Histogram Comparison")
961  leg = ROOT.TLegend(0.6,0.99,0.89,0.8)
962  histoleg = ROOT.TLegend(0.5,0.8,0.89,0.89)
963 
964  #
965 
966  (graph1,histo1,mean1) = newGraphAndHisto(histoleg,leg,npoints1,nbins1,min_val1,max_val1,data1,0,prevrev)
967  hsStack.Add(histo1)
968  (graph2,histo2,mean2) = newGraphAndHisto(histoleg,leg,npoints2,nbins2,min_val2,max_val2,data2,1,prevrev)
969  hsStack.Add(histo2)
970 
971  (biggestLastEvt,biggestMaxval, trashthis) = getTwoGraphLimits(last_event1,max_val1,last_event2,max_val2,min_val1,min_val2)
972 
973  (changegraph,chgleg) = getTimingDiff(data1,data2,npoints2,biggestLastEvt,biggestMaxval)
974  setupSuperimpose(graph1,graph2,biggestLastEvt,biggestMaxval)
975  avg_line1 = getMeanLines(mean1,last_event1,0)
976  avg_line2 = getMeanLines(mean2,last_event2,1)
977 
978  #
979  # Create a one dimensional function and draw it
980  #
981  histo1.GetXaxis().SetTitle("s")
982  graph_canvas = drawGraphs(graph1,graph2,avg_line1,avg_line2,leg)
983  changes_canvas = drawChanges(changegraph,chgleg)
984  histo_canvas = drawHistos(hsStack,histoleg)
985 
986  newrootfile = None
987  if batch:
988 
989  newrootfile = createROOT(outdir,rootfilename)
990 
991  cput = ROOT.TTree()
992  # array(typecode, initializer)
993  # typecode is i for int, f for float etc.
994  tot_a1 = array( "f", [ 0 ] )
995  tot_a2 = array( "f", [ 0 ] )
996 
997  tot_a1[0] = mean1
998  tot_a2[0] = mean2
999 
1000  cput.Branch("total1",tot_a1,"total1/F")
1001  cput.Branch("total2",tot_a2,"total2/F")
1002  cput.Fill()
1003  cput.Write("cpu_time_tuple",ROOT.TObject.kOverwrite)
1004 
1005  names = ["graphs.png","changes.png","histos.png"]
1006 
1007  graph_canvas.Print( os.path.join(outdir,names[0]),"png")
1008  changes_canvas.Print(os.path.join(outdir,names[1]),"png")
1009  histo_canvas.Print( os.path.join(outdir,names[2]),"png")
1010 
1011  map(lambda x:x.Write(),[graph1,graph2,changegraph,hsStack,histo1,histo2])
1012 
1013  graph_canvas.Write() # to file
1014  changes_canvas.Write()
1015  histo_canvas.Write()
1016  newrootfile.Close()
1017 
1018  return names
1019  else:
1020 
1021  while graph_canvas or histo_canvas or changes_canvas:
1022  time.sleep(2.5)
1023  return 0
1024 
def cmpTimingReport(rootfilename, outdir, oldLogfile, newLogfile, secsperbin, batch=True, prevrev="")
def getMeanLines(avg, last_event, graph_num)
Plot the mean line on a graph.
def drawHistos(histo_stack, hstleg)
Draw superimposed histograms on a separate canvas.
def setBatch()
Setup PyRoot as a batch run.
def drawGraphs(graph1, graph2, avg1, avg2, leg)
Draw superimposed graphs on a separate canvas.
def createROOT(outdir, filename)
Create the root file to save the graphs in.
def newGraphAndHisto(histoleg, leg, npoints, nbins, min_val, max_val, data, graph_num, prevrev="")
Create a new timing graph and histogram.
def getLimits(data, secsperbin)
Get limits to plot the graph.
def getTimingLogData(logfile_name)
Parse timing data from log file.
def getTwoGraphLimits(last_event1, max_val1, last_event2, max_val2, min_val1=-1, min_val2=-1)
Get limits for two graphs that will be superimposed upon one another.
def drawChanges(graph, chgleg)
Draw data differences (comparison between two data sets or releases) on a separate canvas...
def getTimingDiff(data1, data2, npoints, last_event, orig_max_val)
Get the difference in timing data (for comparison of two releases)
def setupSuperimpose(graph1, graph2, last_event, max_val, reporttype=0, title="")
Setup graph information for one graph (no need to it on both if they are superimposed) ...
def cmsPerfRegress.createROOT (   outdir,
  filename 
)

Create the root file to save the graphs in.

Definition at line 146 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport(), and cmpTimingReport().

146 def createROOT(outdir,filename):
147 
148  # Save in file
149  rootfilename = os.path.join(outdir,filename)
150  myfile = None
151  exists = os.path.exists(rootfilename)
152  if exists:
153  myfile=ROOT.TFile(rootfilename,'UPDATE')
154  else:
155  myfile=ROOT.TFile(rootfilename,'RECREATE')
156  return myfile
157 
def createROOT(outdir, filename)
Create the root file to save the graphs in.
def cmsPerfRegress.createSimplMemGraphs (   data,
  npoints,
  graph_num,
  legs,
  prevrev = "" 
)

Create simple memory check graphs.

Definition at line 550 of file cmsPerfRegress.py.

References objects.autophobj.float, and str.

Referenced by cmpSimpMemReport().

550 def createSimplMemGraphs(data,npoints,graph_num,legs,prevrev=""):
551  colors = [2,4]
552  values = ["vsize", "rss"]
553 
554  prevRevName = "???"
555  if not prevrev == "":
556  (head, tail) = os.path.split(prevrev)
557  prevRevName = os.path.basename(tail)
558 
559  releaseNames = ["Previous (%s)" % prevRevName,_cmsver]
560 
561  #fill the graphs
562  graphs = []
563  minim = -1
564  peak = -1
565  peaks = []
566  minims = []
567  idx = 0
568  for value in values:
569  leg = legs[idx]
570 
571  graph = ROOT.TGraph(npoints)
572  graph.SetTitle(value)
573  graph.SetLineColor(colors[graph_num])
574  graph.SetMarkerStyle(8)
575  graph.SetMarkerSize(.7)
576  graph.SetMarkerColor(1)
577  graph.SetLineWidth(3)
578  graph.GetXaxis().SetTitle("Event")
579  graph.GetYaxis().SetTitleOffset(1.3)
580  graph.GetYaxis().SetTitle("MB")
581 
582  total = 0
583  point_counter=0
584  rms = 0
585  first = True
586  for event_number,vals_dict in data:
587  if first:
588  minim = vals_dict[value]
589  peak = vals_dict[value]
590  first = False
591  if vals_dict[value] > peak:
592  peak = vals_dict[value]
593  if vals_dict[value] < minim:
594  minim = vals_dict[value]
595  graph.SetPoint(point_counter, event_number, vals_dict[value])
596  total += vals_dict[value]
597  rms += vals_dict[value] * vals_dict[value]
598  point_counter+=1
599 
600  rms = math.sqrt(rms / float(point_counter))
601  mean = total / float(point_counter)
602  last_event=data[-1][0]
603  peaks.append(peak)
604  minims.append(minim)
605  graph.GetXaxis().SetRangeUser(0,last_event+1)
606  leg.AddEntry(graph , "%s release" % releaseNames[graph_num], "l")
607  leg.AddEntry(graph , "Mean: %s" % str(mean) , "l")
608  leg.AddEntry(graph , "RMS : %s" % str(rms) , "l")
609  leg.AddEntry(graph , "Peak: %s" % str(peak) , "l")
610  graphs.append(graph)
611  idx += 1
612 
613  return (graphs[0] , last_event, peaks[0], minims[0], graphs[1], last_event, peaks[1], minims[1])
614 
def createSimplMemGraphs(data, npoints, graph_num, legs, prevrev="")
Create simple memory check graphs.
#define str(s)
def cmsPerfRegress.drawChanges (   graph,
  chgleg 
)

Draw data differences (comparison between two data sets or releases) on a separate canvas.

Definition at line 493 of file cmsPerfRegress.py.

Referenced by cmpTimingReport().

493 def drawChanges(graph,chgleg):
494  graph_canvas = ROOT.TCanvas("change_canvas")
495  graph_canvas.cd()
496  graph.Draw("ALP")
497  chgleg.Draw()
498  return graph_canvas
499 
def drawChanges(graph, chgleg)
Draw data differences (comparison between two data sets or releases) on a separate canvas...
def cmsPerfRegress.drawGraphs (   graph1,
  graph2,
  avg1,
  avg2,
  leg 
)

Draw superimposed graphs on a separate canvas.

Definition at line 470 of file cmsPerfRegress.py.

Referenced by cmpTimingReport().

470 def drawGraphs(graph1,graph2,avg1,avg2,leg):
471  graph_canvas = ROOT.TCanvas("graph_canvas")
472  graph_canvas.cd()
473  graph1.Draw("ALP")
474  graph2.Draw("LP")
475  avg1.Draw("Same")
476  avg2.Draw("Same")
477  leg.Draw()
478  return graph_canvas
479 
def drawGraphs(graph1, graph2, avg1, avg2, leg)
Draw superimposed graphs on a separate canvas.
def cmsPerfRegress.drawHistos (   histo_stack,
  hstleg 
)

Draw superimposed histograms on a separate canvas.

Definition at line 483 of file cmsPerfRegress.py.

Referenced by cmpTimingReport().

483 def drawHistos(histo_stack,hstleg):
484  histo_canvas = ROOT.TCanvas("histo_canvas")
485  histo_canvas.cd()
486  histo_stack.Draw("nostack")
487  hstleg.Draw()
488  return histo_canvas
489 
def drawHistos(histo_stack, hstleg)
Draw superimposed histograms on a separate canvas.
def cmsPerfRegress.drawMemChangeGraphs (   graph,
  leg,
  memtype,
  stepname 
)

Draw the comparison graphs of two memory graphs.

Definition at line 712 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport().

712 def drawMemChangeGraphs(graph,leg,memtype,stepname):
713  graph_canvas=ROOT.TCanvas("%s_%s_change_canvas" % (memtype,stepname))
714  graph_canvas.cd()
715  graph.Draw("ALP" )
716  leg.Draw()
717  graph_canvas.ForceUpdate()
718  graph_canvas.Flush()
719  return graph_canvas
720 
def drawMemChangeGraphs(graph, leg, memtype, stepname)
Draw the comparison graphs of two memory graphs.
def cmsPerfRegress.drawMemGraphs (   graph1,
  graph2,
  min_val,
  max_val,
  last_event,
  leg,
  memtype,
  stepname 
)

Draw two memory graphs superimposed on one another.

Definition at line 697 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport().

697 def drawMemGraphs(graph1,graph2,min_val,max_val,last_event,leg,memtype,stepname):
698  graph_canvas=ROOT.TCanvas("%s_%s_canvas" % (memtype,stepname))
699  graph_canvas.cd()
700  graph1.GetYaxis().SetRangeUser(min_val,max_val)
701  graph1.GetXaxis().SetRangeUser(0,last_event)
702  graph1.Draw("ALP")
703  graph2.Draw("LP" )
704  leg.Draw()
705  graph_canvas.ForceUpdate()
706  graph_canvas.Flush()
707  return graph_canvas
708 
def drawMemGraphs(graph1, graph2, min_val, max_val, last_event, leg, memtype, stepname)
Draw two memory graphs superimposed on one another.
def cmsPerfRegress.get_max (   data,
  index = 1 
)

Get max value in data set.

Definition at line 111 of file cmsPerfRegress.py.

Referenced by getLimits(), and getTimingDiff().

111 def get_max(data,index=1):
112  max_time=-1
113  for el in data:
114  sec=el[index]
115  if max_time<sec:
116  max_time=sec
117  return max_time
118 
def get_max(data, index=1)
Get max value in data set.
def cmsPerfRegress.get_min (   data,
  index = 1 
)

Get min value in data set.

Definition at line 122 of file cmsPerfRegress.py.

Referenced by getLimits(), and getTimingDiff().

122 def get_min(data,index=1):
123  min_time=1e20
124  for el in data:
125  sec=el[index]
126  if min_time>sec:
127  min_time=sec
128  return min_time
129 
def get_min(data, index=1)
Get min value in data set.
def cmsPerfRegress.getLimits (   data,
  secsperbin 
)

Get limits to plot the graph.

Definition at line 341 of file cmsPerfRegress.py.

References get_max(), get_min(), and createfilelist.int.

Referenced by cmpTimingReport().

341 def getLimits(data,secsperbin):
342  min_val=get_min(data,1)
343  max_val=get_max(data,1)
344  interval=int(max_val-min_val)
345 
346  min_val=min_val-interval*0.2
347  max_val=max_val+interval*0.2
348  interval=int(max_val-min_val)
349 
350  nbins=int(interval/secsperbin)
351 
352  npoints=len(data)
353 
354  last_event=data[-1][0]
355 
356  return (min_val,max_val,interval,npoints,last_event)
357 
def get_min(data, index=1)
Get min value in data set.
def getLimits(data, secsperbin)
Get limits to plot the graph.
def get_max(data, index=1)
Get max value in data set.
def cmsPerfRegress.getMeanLines (   avg,
  last_event,
  graph_num 
)

Plot the mean line on a graph.

Definition at line 390 of file cmsPerfRegress.py.

Referenced by cmpTimingReport().

390 def getMeanLines(avg,last_event,graph_num):
391  colors = [2,4]
392  avg_line=ROOT.TLine(1,avg,last_event,avg)
393  avg_line.SetLineColor(colors[graph_num])
394  avg_line.SetLineWidth(2)
395 
396  return avg_line
397 
def getMeanLines(avg, last_event, graph_num)
Plot the mean line on a graph.
def cmsPerfRegress.getMemDiff (   data1,
  data2,
  npoints,
  last_event,
  orig_max_val,
  stepname,
  rss = False 
)

Produce the difference of two memory data sets.

Definition at line 618 of file cmsPerfRegress.py.

References objects.autophobj.float, createfilelist.int, and str.

Referenced by cmpSimpMemReport().

618 def getMemDiff(data1,data2,npoints,last_event,orig_max_val,stepname,rss=False):
619  data3 = []
620  memtype = "vsize"
621  if rss:
622  memtype = "rss"
623 
624  graph=ROOT.TGraph(npoints)
625  total = 0
626  rms = 0
627  evt_counter=0
628  peak = -1
629  minum = -1
630  first = True
631  for x in range(len(data2)):
632  try:
633  (evtnum2,valdict2) = data2[x]
634  (evtnum1,valdict1) = data1[x]
635  if evtnum2 == evtnum1:
636  diffMBytes = valdict2[memtype] - valdict1[memtype]
637 
638  if first:
639  peak = diffMBytes
640  minum = diffMBytes
641  first = False
642  if diffMBytes > peak:
643  peak = diffMBytes
644  if diffMBytes < minum:
645  minum = diffMBytes
646  graph.SetPoint(evt_counter,evtnum2,diffMBytes)
647  evt_counter+=1
648  total += diffMBytes
649  rms += (diffMBytes * diffMBytes)
650  except IndexError:
651  pass
652  except ValueError:
653  pass
654 
655  mean = total / evt_counter
656  rms = math.sqrt(rms / float(evt_counter))
657 
658  min_val = minum
659  max_val = peak
660  interval = int(max_val-min_val)
661 
662  min_val=min_val-interval*0.2
663  max_val=max_val+interval*0.2
664  interval=int(max_val-min_val)
665  # Determine the max value to be something that makes the scale similar to what
666  # the original graph had. Unless we can't seem the maximum value.
667 
668  new_max = min_val + orig_max_val
669  if new_max < max_val:
670  pass
671  else :
672  max_val = new_max
673 
674  graph.SetTitle("Change in %s memory usage for each event between revs for step %s" % (memtype,stepname))
675  graph.SetName('MemoryUsagePerEvent')
676  graph.GetXaxis().SetTitle("Event Number")
677  graph.GetYaxis().SetTitle("Change in memory usage between revs (MBs)")
678  graph.GetYaxis().SetTitleOffset(1.3)
679  graph.SetLineColor(2)
680  graph.SetMarkerStyle(8)
681  graph.SetMarkerSize(.7)
682  graph.SetMarkerColor(1)
683  graph.SetLineWidth(3)
684  graph.GetXaxis().SetLimits(0,last_event)
685  graph.GetYaxis().SetRangeUser(min_val,max_val)
686  leg = ROOT.TLegend(0.5,0.7,0.89,0.89)
687  leg.AddEntry(graph, "Mean: %s" % str(mean), "l")
688  leg.AddEntry(graph, "RMS : %s" % str(rms) , "l")
689  leg.AddEntry(graph, "Peak: %s" % str(peak), "l")
690  leg.AddEntry(graph, "Trough: %s" % str(minum) , "l")
691 
692  return (graph,leg)
693 
def getMemDiff(data1, data2, npoints, last_event, orig_max_val, stepname, rss=False)
Produce the difference of two memory data sets.
#define str(s)
def cmsPerfRegress.getMemOrigScale (   fst_min,
  snd_min,
  fst_max,
  snd_max 
)

Definition at line 721 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport().

721 def getMemOrigScale(fst_min,snd_min,fst_max,snd_max):
722  minim = fst_min
723  if snd_min < minim:
724  minim = snd_min
725  maxim = fst_max
726  if snd_max > maxim:
727  maxim = snd_max
728  return (minim,maxim)
729 
def getMemOrigScale(fst_min, snd_min, fst_max, snd_max)
def cmsPerfRegress.getNpoints (   data)

Definition at line 516 of file cmsPerfRegress.py.

References edm.print().

516 def getNpoints(data):
517  new_data=[]
518  try:
519  #This was necessary due to a bug in the getSimpleMemLogData parsing!!! no more necessary!
520  if data[0][0]==data[1][0]:
521  print('Two modules seem to have some output.\nCollapsing ...')
522  i=0
523  while True:
524  dataline1=data[i]
525  i+=1
526  dataline2=data[i]
527  new_eventnumber=dataline1[0]
528  new_vsize=dataline2[1]['vsize']
529  new_delta_vsize=dataline1[1]['delta_vsize']+dataline2[1]['delta_vsize']
530  new_rss=dataline2[1]['rss']
531  new_delta_rss=dataline1[1]['delta_rss']+dataline2[1]['delta_rss']
532 
533  new_data.append((new_eventnumber,{'vsize':new_vsize,
534  'delta_vsize':new_delta_vsize,
535  'rss':new_rss,
536  'delta_rss':new_delta_rss}))
537  i+=1
538  if i==len(data): break
539 
540  data=new_data
541  print('Collapsing: Done!')
542  except IndexError:
543  pass
544 
545  return (data,len(data))
546 
def getNpoints(data)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmsPerfRegress.getParameters ( )

Definition at line 70 of file cmsPerfRegress.py.

References edm.print().

Referenced by _main().

71  parser = opt.OptionParser()
72  #
73  # Options
74  #
75  parser.add_option('-n',
76  type="int",
77  help='Number of secs per bin. Default is 1.' ,
78  default=1,
79  dest='startevt')
80  parser.add_option('-t',
81  '--report-type',
82  type="choice",
83  choices= ("timing", "simplememory","edmsize","igprof","callgrind",""),
84  help='Type of report to perform regrssion on. Default is TimingReport.' ,
85  default="timing",
86  dest='reporttype')
87  parser.add_option('-i',
88  '--IgProfMemOption',
89  type="choice",
90  choices= ("-y MEM_TOTAL", "-y MEM_LIVE",""),
91  help='Eventual IgProfMem counter to use for the regression. Default is no argument (IgProfPerf).' ,
92  default="",
93  dest='igprofmem')
94  (options,args) = parser.parse_args()
95  if len(args) < 2:
96  parser.error("ERROR: Not enough arguments")
97  sys.exit()
98 
99 
100  path1 = os.path.abspath(args[0])
101  path2 = os.path.abspath(args[1])
102  if os.path.exists(path1) and os.path.exists(path2):
103  return (path1, path2, options.startevt, options.reporttype, options.igprofmem)
104  else:
105  print("Error: one of the paths does not exist")
106  sys.exit()
107 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmsPerfRegress.getSimpleMemLogData (   logfile_name,
  startevt,
  candle 
)

Parse memory check data from log file.

Definition at line 186 of file cmsPerfRegress.py.

References objects.autophobj.float, createfilelist.int, and edm.print().

Referenced by cmpSimpMemReport().

186 def getSimpleMemLogData(logfile_name,startevt, candle):
187  data=[]
188  values_set=('vsize','delta_vsize','rss','delta_rss')
189 
190  # open file and read it and fill the structure!
191  logfile=open(logfile_name,'r')
192  logfile_lines=logfile.readlines()
193  logfile.close()
194 
195  step = ""
196  steps = []
197  #print candle
198  #print CandFname[candle]
199  #Get the step from log filename:
200 
201  #Catching the case of command line use in which the candle is unknown (and the log name does not match the perfsuite naming convention
202  if candle:
203  stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],"TimingReport"))
204  else:
205  stepreg = re.compile("([^_]*(_PILEUP)?)_%s((.log)|(.gz))?"%"TimingReport")
206 
207  #print logfile_name
208  found=stepreg.search(logfile_name)
209  if found:
210  step=found.groups()[0]
211  print("Determined step from log filename to be %s"%step)
212  else:
213  print("Could not determine step from log filename")
214 
215  #steps.append((step,data))
216 
217  #Rewriting the following code... what a mess!
218  # we get the info we need!
219  #i=0
220  #while i < len(logfile_lines):
221  #line=logfile_lines[i]
222  #Format has changed... we use the output of individual steps, so no need to read into the logfile to find which step we are
223  #referring too (by the way it would not work now!)... the step info comes from the logfilename done above...
224  #if "RelValreport" in line and "cmsDriver" in line and "step" in line:
225  # stepreg = re.compile("--step=([^ ]*)")
226  # found = stepreg.search(line)
227  # if found:
228  # if step == "":
229  # step = found.groups()[0]
230  # else:
231  # steps.append((step,data))
232  # step = found.groups()[0]
233  # data = []
234  #if '%MSG-w MemoryCheck:' in line:
235  # line=line[:-1] #no \n!
236  # line_content_list=line.split(' ')
237  # event_number=int(line_content_list[-1])
238  # if event_number<startevt:
239  # i+=1
240  # continue
241  # i+=1 # we inspect the following line
242  # try:
243  # line=logfile_lines[i]
244  # except IndexError:
245  # continue
246  # line=line[:-1] #no \n!
247  # line_content_list=line.split(' ')
248  # vsize=float(line_content_list[4])
249  # delta_vsize=float(line_content_list[5])
250  # rss=float(line_content_list[7])
251  # delta_rss=float(line_content_list[8])
252  #
253  # data.append((event_number,{'vsize':vsize,
254  # 'delta_vsize':delta_vsize,
255  # 'rss':rss,
256  # 'delta_rss':delta_rss}))
257  #i += 1
258  event_number= startevt
259  for line in logfile_lines:
260  #Match SimpleMemoryCheck output to get the event number
261  if '%MSG-w MemoryCheck:' in line: #Harcoded based on format: %MSG-w MemoryCheck: PostModule 12-Jan-2009 16:00:29 CET Run: 1 Event: 1
262  tokens=line.split()
263  if int(tokens[-1])>= startevt:
264  event_number=int(tokens[-1])
265  if 'VSIZE' in line: #Harcoded based on format: MemoryCheck: event : VSIZE 648.426 0 RSS 426.332 0
266  tokens=line.split()
267  vsize=float(tokens[4])
268  delta_vsize=float(tokens[5])
269  rss=float(tokens[7])
270  delta_rss=float(tokens[8])
271  data.append((event_number,{'vsize':vsize,
272  'delta_vsize':delta_vsize,
273  'rss':rss,
274  'delta_rss':delta_rss
275  }
276  )
277  )
278 
279  if not len(data) == 0:
280  #print "!!!!!!!!!!!!!Adding step %s and data!"%step
281  steps.append((step,data))
282 
283  #print "PRINTOUT@@@@@@"
284  #print steps
285  return steps
286 
def getSimpleMemLogData(logfile_name, startevt, candle)
Parse memory check data from log file.
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmsPerfRegress.getTimingDiff (   data1,
  data2,
  npoints,
  last_event,
  orig_max_val 
)

Get the difference in timing data (for comparison of two releases)

Definition at line 401 of file cmsPerfRegress.py.

References get_max(), get_min(), createfilelist.int, genParticles_cff.map, and str.

Referenced by cmpTimingReport().

401 def getTimingDiff(data1,data2,npoints,last_event,orig_max_val):
402  data3 = []
403  for x in range(len(data2)):
404  try:
405  if data2[x][0] == data1[x][0]:
406  avgEventNum = data2[x][0]
407  diffSecs = data2[x][1] - data1[x][1]
408  data3.append((avgEventNum,diffSecs))
409  except IndexError:
410  pass
411  except ValueError:
412  pass
413 
414  graph=ROOT.TGraph(npoints)
415 
416  evt_counter=0
417  peak = data3[0][1]
418  for evt_num,secs in data3:
419  if secs > peak:
420  peak = secs
421  graph.SetPoint(evt_counter,evt_num,secs)
422  evt_counter+=1
423 
424  allsecs = []
425  map(lambda x: allsecs.append(x[1]),data3)
426  total = reduce(lambda x,y: x + y,allsecs)
427  mean = total / evt_counter
428  rms = math.sqrt(reduce(lambda x,y: x + y,map(lambda x: x * x,allsecs)) / evt_counter)
429 
430  min_val=get_min(data3,1)
431  max_val=get_max(data3,1)
432  interval=int(max_val-min_val)
433 
434  min_val=min_val-interval*0.2
435  max_val=max_val+interval*0.2
436  interval=int(max_val-min_val)
437 
438  # Determine the max value to be something that makes the scale similar to what
439  # the original graph had. Unless we can't seem the maximum value.
440 
441  new_max = min_val + orig_max_val
442  if new_max < max_val:
443  pass
444  else :
445  max_val = new_max
446 
447  graph.SetTitle('Change in processing time for each event between revs')
448  graph.SetName('SecondsPerEvent')
449  graph.GetXaxis().SetTitle("Event Number")
450  graph.GetYaxis().SetTitle("Change in processing time between revs (s)")
451  graph.GetYaxis().SetTitleOffset(1.3)
452  graph.SetLineColor(2)
453  graph.SetMarkerStyle(8)
454  graph.SetMarkerSize(.7)
455  graph.SetMarkerColor(1)
456  graph.SetLineWidth(3)
457  graph.GetXaxis().SetLimits(0,last_event)
458  graph.GetYaxis().SetRangeUser(min_val,max_val)
459  leg = ROOT.TLegend(0.5,0.7,0.89,0.89)
460  leg.AddEntry(graph, "Mean: %s" % str(mean), "l")
461  leg.AddEntry(graph, "RMS : %s" % str(rms) , "l")
462  leg.AddEntry(graph, "Peak: %s" % str(peak), "l")
463  leg.AddEntry(graph, "Total time change: %s" % str(total) , "l")
464 
465  return (graph,leg)
466 
def get_min(data, index=1)
Get min value in data set.
def get_max(data, index=1)
Get max value in data set.
#define str(s)
def getTimingDiff(data1, data2, npoints, last_event, orig_max_val)
Get the difference in timing data (for comparison of two releases)
def cmsPerfRegress.getTimingLogData (   logfile_name)

Parse timing data from log file.

Definition at line 161 of file cmsPerfRegress.py.

References objects.autophobj.float, and createfilelist.int.

Referenced by cmpTimingReport().

161 def getTimingLogData(logfile_name):
162  data=[]
163 
164  # open file and read it and fill the structure!
165  logfile=open(logfile_name,'r')
166  logfile_lines=logfile.readlines()
167  logfile.close()
168 
169  # we get the info we need!
170  i=0
171  while i < len(logfile_lines):
172  line=logfile_lines[i]
173  if 'TimeEvent>' in line:
174  line=line.strip()
175  line_content_list = line.split(' ')[0:]
176  event_number = int(line_content_list[1])
177  seconds = float(line_content_list[3])
178  data.append((event_number,seconds))
179  i+=1
180 
181  return data
182 
def getTimingLogData(logfile_name)
Parse timing data from log file.
def cmsPerfRegress.getTwoGraphLimits (   last_event1,
  max_val1,
  last_event2,
  max_val2,
  min_val1 = -1,
  min_val2 = -1 
)

Get limits for two graphs that will be superimposed upon one another.

Definition at line 503 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport(), and cmpTimingReport().

503 def getTwoGraphLimits(last_event1,max_val1,last_event2,max_val2,min_val1=-1,min_val2=-1):
504  biggestLastEvt = last_event1
505  biggestMaxval = max_val1
506  lowest_val = min_val1
507 
508  if min_val2 < lowest_val:
509  lowest_val = min_val2
510  if last_event2 > biggestLastEvt:
511  biggestLastEvt = last_event2
512  if max_val2 > biggestMaxval:
513  biggestMaxval = max_val2
514  return (biggestLastEvt,biggestMaxval,lowest_val)
515 
def getTwoGraphLimits(last_event1, max_val1, last_event2, max_val2, min_val1=-1, min_val2=-1)
Get limits for two graphs that will be superimposed upon one another.
def cmsPerfRegress.newGraphAndHisto (   histoleg,
  leg,
  npoints,
  nbins,
  min_val,
  max_val,
  data,
  graph_num,
  prevrev = "" 
)

Create a new timing graph and histogram.

Definition at line 291 of file cmsPerfRegress.py.

References genParticles_cff.map, and str.

Referenced by cmpTimingReport().

291 def newGraphAndHisto(histoleg,leg,npoints,nbins,min_val,max_val,data,graph_num,prevrev=""):
292 
293  colors = [2,4]
294  prevRevName = "???"
295  if not prevrev == "":
296  (head, tail) = os.path.split(prevrev)
297  prevRevName = os.path.basename(tail)
298  releaseNames = ["Previous (%s)" % prevRevName,_cmsver]
299 
300  histo=ROOT.TH1F("Seconds per event (histo: %s)" % graph_num,'Seconds per event',nbins,min_val,max_val)
301 
302  graph=ROOT.TGraph(npoints)
303 
304  evt_counter=0
305  peak = data[0][1]
306  for evt_num,secs in data:
307  if secs > peak:
308  peak = secs
309  graph.SetPoint(evt_counter,evt_num,secs)
310  histo.Fill(secs)
311  evt_counter+=1
312 
313  allsecs = []
314  map(lambda x: allsecs.append(x[1]),data)
315  total = reduce(lambda x,y: x + y,allsecs)
316  mean = total / evt_counter
317  rms = math.sqrt(reduce(lambda x,y: x + y,map(lambda x: x * x,allsecs)) / evt_counter)
318 
319 
320  graph.SetMarkerStyle(8)
321  graph.SetMarkerSize(.7)
322  graph.SetMarkerColor(1)
323  graph.SetLineWidth(3)
324  graph.SetLineColor(colors[graph_num]) # for each iterate through colors
325  histo.SetLineColor(colors[graph_num])
326  histo.SetStats(1)
327  histoleg.AddEntry(histo, "%s release" % releaseNames[graph_num], "l")
328  leg.AddEntry(graph , "%s release" % releaseNames[graph_num], "l")
329  leg.AddEntry(graph , "Mean: %s" % str(mean) , "l")
330  leg.AddEntry(graph , "RMS : %s" % str(rms) , "l")
331  leg.AddEntry(graph , "Peak: %s" % str(peak) , "l")
332  leg.AddEntry(graph , "Total time: %s" % str(total) , "l")
333  if graph_num == 0 :
334  histo.SetFillColor(colors[graph_num])
335 
336  return (graph,histo,mean)
337 
def newGraphAndHisto(histoleg, leg, npoints, nbins, min_val, max_val, data, graph_num, prevrev="")
Create a new timing graph and histogram.
#define str(s)
def cmsPerfRegress.perfreport (   perftype,
  file1,
  file2,
  outdir,
  IgProfMemopt = "" 
)

Definition at line 1049 of file cmsPerfRegress.py.

References edm.print(), and rmtree().

Referenced by cmpCallgrindReport(), cmpEdmSizeReport(), and cmpIgProfReport().

1049 def perfreport(perftype,file1,file2,outdir,IgProfMemopt=""):
1050  src = ""
1051  try:
1052  src = os.environ["CMSSW_SEARCH_PATH"]
1053  except KeyError as detail:
1054  print("ERROR: scramv1 environment could not be located", detail)
1055 
1056  vars = src.split(":")
1057  loc = vars[0]
1058 
1059  proftype = ""
1060  if perftype == 0: # EdmSize
1061  proftype = "-fe"
1062  elif perftype == 1: # IgProf
1063  proftype = "-fi"
1064  else: # Callgrind
1065  proftype = "-ff"
1066 
1067  cmssw_release_base = ""
1068  cmssw_data = ""
1069  try:
1070  cmssw_release_base = os.environ['CMSSW_RELEASE_BASE']
1071  cmssw_data = os.environ['CMSSW_DATA_PATH']
1072  except KeyError as detail:
1073  raise PerfReportErr
1074 
1075  xmlfile = os.path.join(cmssw_release_base,"src","Validation","Performance","doc","regress.xml")
1076 
1077  prRoot = "/afs/cern.ch/user/g/gbenelli/public/PerfReport2/2.0.1"
1078 
1079  # this might be useful at some point
1080  #cd %s ; eval `scramv1 runtime -csh` ; source $CMSSW_DATA_PATH/perfreport/2.0.0/etc/profile.d/init.csh; cd - ; %s\"" % (loc,perfcmd)
1081 
1082  # Before adding Danilo's 2.1 we did this
1083  #perfcmd = "perfreport -tmp %s -i %s -r %s -o %s" % (proftype,file2,file1,outdir)
1084  #cmd = "tcsh -c \"source %s/perfreport/2.0.0/etc/profile.d/init.csh; cd - ; %s\"" % (cmssw_data,perfcmd)
1085 
1086  # now we do
1087 
1088  tmpdir = tmp.mkdtemp(prefix=os.path.join(outdir,"tmp"))
1089 
1090  perfcmd = "%s %s %s -c %s -t%s -i %s -r %s -o %s" % (os.path.join(prRoot,"bin","perfreport"),proftype,IgProfMemopt,xmlfile,tmpdir,file2,file1,outdir)
1091  cmd = "tcsh -c \"cd %s ; eval `scramv1 runtime -csh` ; cd - ;source %s/etc/profile.d/init.csh ; %s\"" % (loc,prRoot,perfcmd)
1092  #Obsolete popen4-> subprocess.Popen
1093  #process = os.popen(cmd)
1094  process = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
1095  exitstat = process.wait()
1096  cmdout = process.stdout.read()
1097  exitstat = process.returncode
1098 
1099  try:
1100  rmtree(tmpdir) #Brute force solution rm -RF tmpdir done in rmtree()
1101  #os.rmdir(tmpdir)
1102  except IOError as detail:
1103  print("WARNING: Could not remove dir because IO%s" % detail)
1104  except OSError as detail:
1105  print("WARNING: Could not remove dir because %s" % detail)
1106 
1107  if True:
1108  print(cmd)
1109  print(cmdout)
1110 
1111  if not exitstat == None:
1112  sig = exitstat >> 16 # Get the top 16 bits
1113  xstatus = exitstat & 0xffff # Mask out all bits except the bottom 16
1114  raise PerfReportErr("ERROR: PerfReport returned a non-zero exit status (%s, SIG_INT = %s) run %s. Dump follows: \n%s" % (perfcmd,xstatus,sig,cmdout))
1115 
1116 
def perfreport(perftype, file1, file2, outdir, IgProfMemopt="")
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmsPerfRegress.rmtree (   path)

Definition at line 1025 of file cmsPerfRegress.py.

References GetRecoTauVFromDQM_MC_cff.next, and edm.print().

Referenced by cmsswFiletrace.cleanupenv(), cmsswConfigtrace.cleanupenv(), showPage.createLogFiles(), and perfreport().

1025 def rmtree(path):
1026  try:
1027  #os.remove(path)
1028  #Brute force solution:
1029  RemoveCmd="rm -Rf %s"%path
1030  os.system(RemoveCmd)
1031  except OSError as detail:
1032  if detail.errno == 39:
1033  try:
1034  gen = os.walk(path)
1035  nodes = next(gen)
1036  nodes[0] = par
1037  nodes[1] = dirs
1038  nodes[2] = files
1039  for f in files:
1040  os.remove(os.path.join(path,f))
1041  for d in dirs:
1042  rmtree(os.path.join(path,d))
1043  except OSError as detail:
1044  print(detail)
1045  except IOError as detail:
1046  print(detail)
1047  os.remove(path)
1048 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def cmsPerfRegress.setBatch ( )

Setup PyRoot as a batch run.

Definition at line 133 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport(), and cmpTimingReport().

133 def setBatch():
134  __argv=sys.argv # trick for a strange behaviour of the TApp..
135  sys.argv=sys.argv[:1]
136  ROOT.gROOT.SetStyle("Plain") # style paranoia
137  sys.argv=__argv
138  #Cannot use this option when the logfile includes
139  #a large number of events... PyRoot seg-faults.
140  #Set ROOT in batch mode to avoid canvases popping up!
141  ROOT.gROOT.SetBatch(1)
142 
def setBatch()
Setup PyRoot as a batch run.
def cmsPerfRegress.setupSuperimpose (   graph1,
  graph2,
  last_event,
  max_val,
  reporttype = 0,
  title = "" 
)

Setup graph information for one graph (no need to it on both if they are superimposed)

Definition at line 361 of file cmsPerfRegress.py.

Referenced by cmpSimpMemReport(), and cmpTimingReport().

361 def setupSuperimpose(graph1,graph2,last_event,max_val,reporttype=0, title = ""):
362  name = ""
363  xtitle = ""
364  ytitle = ""
365  if reporttype == 0:
366  title = 'Seconds per event'
367  name = 'SecondsPerEvent'
368  xtitle = "Event"
369  ytitle = "Processing time for each event (s)"
370  graph1.GetYaxis().SetRangeUser(0,max_val)
371  graph2.GetYaxis().SetRangeUser(0,max_val)
372  elif reporttype == 1:
373  name = "%s_graph" % title
374  xtitle = "Event"
375  ytitle = "MB"
376 
377  graph1.SetTitle(title)
378  graph1.SetName(name)
379  graph1.GetXaxis().SetTitle(xtitle)
380  graph1.GetYaxis().SetTitleOffset(1.3)
381  graph1.GetYaxis().SetTitle(ytitle)
382  graph1.GetXaxis().SetLimits(0,last_event)
383  # Do I need to set limits on graph 2? I don't know
384  # I'm doing it anyway, can't hurt.
385  graph2.GetXaxis().SetLimits(0,last_event)
386 
def setupSuperimpose(graph1, graph2, last_event, max_val, reporttype=0, title="")
Setup graph information for one graph (no need to it on both if they are superimposed) ...
def cmsPerfRegress.ungzip (   inf,
  outh 
)

Definition at line 1120 of file cmsPerfRegress.py.

References edm.print().

1120 def ungzip(inf,outh):
1121  gzf = gzip.open(inf,"r")
1122  print("ungzipping")
1123  for char in gzf:
1124  os.write(outh,char)
1125  os.close(outh)
1126  print("finish ungzipping")
1127  gzf.close()
1128 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def ungzip(inf, outh)
def cmsPerfRegress.ungzip2 (   inf,
  out 
)

Definition at line 1129 of file cmsPerfRegress.py.

Referenced by cmpIgProfReport().

1129 def ungzip2(inf,out):
1130  os.system("gzip -c -d %s > %s" % (inf,out))
1131 
def ungzip2(inf, out)

Variable Documentation

cmsPerfRegress._cmsver
private

Definition at line 16 of file cmsPerfRegress.py.

cmsPerfRegress.values_set

Definition at line 17 of file cmsPerfRegress.py.