12 """ Parses logfile_name and create an html report
13 with information and plots, at the outdir path.
14 Graphs' production is also done here.
19 logfile = open(logfile_name,
'r')
20 logfile_lines = iter(logfile.readlines())
24 for line
in logfile_lines:
26 if 'TimeEvent>' in line:
28 content = line.split(
' ')
29 event = int(content[1])
30 seconds = float(content[3])
33 elif 'TimeReport' in line:
35 report += line.replace(
'TimeReport',
'\n')
36 elif 'headings' in line:
38 elif 'complete' in line:
39 report += line.replace(
'TimeReport',
'\n')
40 for count
in range(12):
41 line =
next(logfile_lines)
45 report += line.replace(
'TimeReport',
'')
51 sys.argv = sys.argv[:1]
52 ROOT.gROOT.SetStyle(
"Plain")
57 ROOT.gROOT.SetBatch(1)
60 rootfilename =
'%s/graphs.root' %outdir
61 myfile = ROOT.TFile(rootfilename,
'RECREATE')
64 min_val = data[
min(data, key=data.get)]
65 max_val = data[
max(data, key=data.get)]
66 interval = max_val-min_val
67 min_val = min_val - (interval*0.2)
68 max_val = max_val + (interval*0.2)
69 interval = max_val - min_val
70 nbins = int(interval/secsperbin)
73 histo = ROOT.TH1F(
'Seconds per event',
'Seconds per event', nbins, min_val, max_val)
74 histo.GetXaxis().SetTitle(
"s")
77 graph = ROOT.TGraph(npoints)
78 graph.SetMarkerStyle(8)
79 graph.SetMarkerSize(.7)
80 graph.SetMarkerColor(1)
83 graph.SetTitle(
'Seconds per event')
84 graph.SetName(
'SecondsPerEvent')
85 graph.GetXaxis().SetTitle(
"Event")
86 last_event =
max(data)
87 graph.GetXaxis().SetLimits(0, last_event)
88 graph.GetYaxis().SetTitleOffset(1.3)
89 graph.GetYaxis().SetTitle(
"s")
90 graph.GetYaxis().SetRangeUser(0, max_val)
93 for event_num
in data.keys():
94 seconds = data[event_num]
95 graph.SetPoint(event_num-1, event_num, seconds)
100 avg_line = ROOT.TLine(1,avg,last_event, avg)
101 avg_line.SetLineColor(4)
102 avg_line.SetLineWidth(2)
104 graph_canvas = ROOT.TCanvas(
'graph_canvas')
107 avg_line.Draw(
"Same")
111 graph_canvas.Print(
"%s/graph.png" %outdir,
"png")
114 histo_canvas = ROOT.TCanvas(
'histo_canvas')
119 histo_canvas.Print(
"%s/histo.png" %outdir,
"png")
128 titlestring =
'<b>Report executed with release %s on %s.</b>\n<br>\n<hr>\n'\
129 %(os.environ[
'CMSSW_VERSION'], time.asctime())
130 html_file_name =
'%s/%s_TimingReport.html' %(outdir, logfile_name[:-4])
131 html_file = open(html_file_name,
'w')
132 html_file.write(
'<html>\n<body>\n'+\
134 html_file.write(
'<table>\n'+\
135 '<tr>\n<td><img src=graph.png></img></td>\n'+\
136 '<td><img src=histo.png></img></td>\n</tr>\n'+\
138 html_file.write(
'<hr>\n<h2>Time Report</h2>\n<pre>\n' + report +
'</pre>\n')
139 html_file.write(
'</body>\n</html>')
145 total_events =
max(data)
146 average_time = total_time / total_events
148 for i
in range(1,
max(data)+1):
149 sum += (data[i]-average_time)**2
150 denominator = total_events**2 - total_events
151 uncertainty =
sqrt(sum/denominator)
155 print '------ Statistics ------'
156 print 'last event = {}'.
format(last_event)
157 print 'Minval = {} maxval = {} interval = {}'.
format(min_val, max_val, interval)
158 print 'Total Time = {}'.
format(total_time)
159 print 'Average Time = {}'.
format(average_time)
160 print 'Uncertainty of Average Time = {} +/- {}'.
format(average_time, uncertainty)