def createBootGraph(data): # html function templates html_srccall = '<div id={6} title="{5}" class="srccall" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;">{0}</div>\n' html_timetotal = '<table class="time1">\n<tr>'\ '<td class="blue">Init process starts @ <b>{0} ms</b></td>'\ '<td class="blue">Last initcall ends @ <b>{1} ms</b></td>'\ '</tr>\n</table>\n' # device timeline devtl = aslib.Timeline(100, 20) # write the test title and general info header devtl.createHeader(sysvals, sysvals.stamp) # Generate the header for this timeline t0 = data.start tMax = data.end tTotal = tMax - t0 if (tTotal == 0): pprint('ERROR: No timeline data') return False user_mode = '%.0f' % (data.tUserMode * 1000) last_init = '%.0f' % (tTotal * 1000) devtl.html += html_timetotal.format(user_mode, last_init) # determine the maximum number of rows we need to draw devlist = [] for p in data.phases: list = data.dmesg[p]['list'] for devname in list: d = aslib.DevItem(0, p, list[devname]) devlist.append(d) devtl.getPhaseRows(devlist, 0, 'start') devtl.calcTotalRows() # draw the timeline background devtl.createZoomBox() devtl.html += devtl.html_tblock.format('boot', '0', '100', devtl.scaleH) for p in data.phases: phase = data.dmesg[p] length = phase['end'] - phase['start'] left = '%.3f' % (((phase['start'] - t0) * 100.0) / tTotal) width = '%.3f' % ((length * 100.0) / tTotal) devtl.html += devtl.html_phase.format(left, width, \ '%.3f'%devtl.scaleH, '%.3f'%devtl.bodyH, \ phase['color'], '') # draw the device timeline num = 0 devstats = dict() for phase in data.phases: list = data.dmesg[phase]['list'] for devname in sorted(list): cls, color = colorForName(devname) dev = list[devname] info = '@|%.3f|%.3f|%.3f|%d' % (dev['start'] * 1000.0, dev['end'] * 1000.0, dev['ulen'] / 1000.0, dev['ret']) devstats[dev['id']] = {'info': info} dev['color'] = color height = devtl.phaseRowHeight(0, phase, dev['row']) top = '%.6f' % ((dev['row'] * height) + devtl.scaleH) left = '%.6f' % (((dev['start'] - t0) * 100) / tTotal) width = '%.6f' % (((dev['end'] - dev['start']) * 100) / tTotal) length = ' (%0.3f ms) ' % ((dev['end'] - dev['start']) * 1000) devtl.html += devtl.html_device.format( dev['id'], devname + length + phase + '_mode', left, top, '%.3f' % height, width, devname, ' ' + cls, '') rowtop = devtl.phaseRowTop(0, phase, dev['row']) height = '%.6f' % (devtl.rowH / 2) top = '%.6f' % (rowtop + devtl.scaleH + (devtl.rowH / 2)) if data.do_one_initcall: if ('ftrace' not in dev): continue cg = dev['ftrace'] large, stats = cgOverview(cg, 0.001) devstats[dev['id']]['fstat'] = stats for l in large: left = '%f' % (((l.time - t0) * 100) / tTotal) width = '%f' % (l.length * 100 / tTotal) title = '%s (%0.3fms)' % (l.name, l.length * 1000.0) devtl.html += html_srccall.format(l.name, left, top, height, width, title, 'x%d' % num) num += 1 continue if ('ftraces' not in dev): continue for cg in dev['ftraces']: left = '%f' % (((cg.start - t0) * 100) / tTotal) width = '%f' % ((cg.end - cg.start) * 100 / tTotal) cglen = (cg.end - cg.start) * 1000.0 title = '%s (%0.3fms)' % (cg.name, cglen) cg.id = 'x%d' % num devtl.html += html_srccall.format(cg.name, left, top, height, width, title, dev['id'] + cg.id) num += 1 # draw the time scale, try to make the number of labels readable devtl.createTimeScale(t0, tMax, tTotal, 'boot') devtl.html += '</div>\n' # timeline is finished devtl.html += '</div>\n</div>\n' # draw a legend which describes the phases by color devtl.html += '<div class="legend">\n' pdelta = 20.0 pmargin = 36.0 for phase in data.phases: order = '%.2f' % ((data.dmesg[phase]['order'] * pdelta) + pmargin) devtl.html += devtl.html_legend.format(order, \ data.dmesg[phase]['color'], phase+'_mode', phase[0]) devtl.html += '</div>\n' hf = open(sysvals.htmlfile, 'w') # add the css extra = '\ .c1 {background:rgba(209,0,0,0.4);}\n\ .c2 {background:rgba(255,102,34,0.4);}\n\ .c3 {background:rgba(255,218,33,0.4);}\n\ .c4 {background:rgba(51,221,0,0.4);}\n\ .c5 {background:rgba(17,51,204,0.4);}\n\ .c6 {background:rgba(34,0,102,0.4);}\n\ .c7 {background:rgba(51,0,68,0.4);}\n\ .c8 {background:rgba(204,255,204,0.4);}\n\ .c9 {background:rgba(169,208,245,0.4);}\n\ .c10 {background:rgba(255,255,204,0.4);}\n\ .vt {transform:rotate(-60deg);transform-origin:0 0;}\n\ table.fstat {table-layout:fixed;padding:150px 15px 0 0;font-size:10px;column-width:30px;}\n\ .fstat th {width:55px;}\n\ .fstat td {text-align:left;width:35px;}\n\ .srccall {position:absolute;font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-radius:5px;border:1px solid black;background:linear-gradient(to bottom right,#CCC,#969696);}\n\ .srccall:hover {color:white;font-weight:bold;border:1px solid white;}\n' aslib.addCSS(hf, sysvals, 1, False, extra) # write the device timeline hf.write(devtl.html) # add boot specific html statinfo = 'var devstats = {\n' for n in sorted(devstats): statinfo += '\t"%s": [\n\t\t"%s",\n' % (n, devstats[n]['info']) if 'fstat' in devstats[n]: funcs = devstats[n]['fstat'] for f in sorted(funcs, key=funcs.get, reverse=True): if funcs[f][0] < 0.01 and len(funcs) > 10: break statinfo += '\t\t"%f|%s|%d",\n' % (funcs[f][0], f, funcs[f][1]) statinfo += '\t],\n' statinfo += '};\n' html = \ '<div id="devicedetailtitle"></div>\n'\ '<div id="devicedetail" style="display:none;">\n'\ '<div id="devicedetail0">\n' for p in data.phases: phase = data.dmesg[p] html += devtl.html_phaselet.format(p + '_mode', '0', '100', phase['color']) html += '</div>\n</div>\n'\ '<script type="text/javascript">\n'+statinfo+\ '</script>\n' hf.write(html) # add the callgraph html if (sysvals.usecallgraph): aslib.addCallgraphs(sysvals, hf, data) # add the test log as a hidden div if sysvals.testlog and sysvals.logmsg: hf.write('<div id="testlog" style="display:none;">\n' + sysvals.logmsg + '</div>\n') # add the dmesg log as a hidden div if sysvals.dmesglog: hf.write('<div id="dmesglog" style="display:none;">\n') for line in data.dmesgtext: line = line.replace('<', '<').replace('>', '>') hf.write(line) hf.write('</div>\n') # write the footer and close aslib.addScriptCode(hf, [data]) hf.write('</body>\n</html>\n') hf.close() return True
def createBootGraph(data): # html function templates html_srccall = '<div id={6} title="{5}" class="srccall" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;">{0}</div>\n' html_timetotal = '<table class="time1">\n<tr>'\ '<td class="blue">Init process starts @ <b>{0} ms</b></td>'\ '<td class="blue">Last initcall ends @ <b>{1} ms</b></td>'\ '</tr>\n</table>\n' # device timeline devtl = aslib.Timeline(100, 20) # write the test title and general info header devtl.createHeader(sysvals, sysvals.stamp) # Generate the header for this timeline t0 = data.start tMax = data.end tTotal = tMax - t0 if(tTotal == 0): print('ERROR: No timeline data') return False user_mode = '%.0f'%(data.tUserMode*1000) last_init = '%.0f'%(tTotal*1000) devtl.html += html_timetotal.format(user_mode, last_init) # determine the maximum number of rows we need to draw devlist = [] for p in data.phases: list = data.dmesg[p]['list'] for devname in list: d = aslib.DevItem(0, p, list[devname]) devlist.append(d) devtl.getPhaseRows(devlist, 0, 'start') devtl.calcTotalRows() # draw the timeline background devtl.createZoomBox() devtl.html += devtl.html_tblock.format('boot', '0', '100', devtl.scaleH) for p in data.phases: phase = data.dmesg[p] length = phase['end']-phase['start'] left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal) width = '%.3f' % ((length*100.0)/tTotal) devtl.html += devtl.html_phase.format(left, width, \ '%.3f'%devtl.scaleH, '%.3f'%devtl.bodyH, \ phase['color'], '') # draw the device timeline num = 0 devstats = dict() csvfile = open(sysvals.csvfile, 'w') writer = csv.writer(csvfile) writer.writerow(['Dev','Duration(ms)']) for phase in data.phases: list = data.dmesg[phase]['list'] for devname in sorted(list): cls, color = colorForName(devname) dev = list[devname] info = '@|%.3f|%.3f|%.3f|%d' % (dev['start']*1000.0, dev['end']*1000.0, dev['ulen']/1000.0, dev['ret']) devstats[dev['id']] = {'info':info} dev['color'] = color height = devtl.phaseRowHeight(0, phase, dev['row']) top = '%.6f' % ((dev['row']*height) + devtl.scaleH) left = '%.6f' % (((dev['start']-t0)*100)/tTotal) width = '%.6f' % (((dev['end']-dev['start'])*100)/tTotal) length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000) devtl.html += devtl.html_device.format(dev['id'], devname+length+phase+'_mode', left, top, '%.3f'%height, width, devname, ' '+cls, '') writer.writerow([devname, (dev['end']-dev['start'])*1000]) rowtop = devtl.phaseRowTop(0, phase, dev['row']) height = '%.6f' % (devtl.rowH / 2) top = '%.6f' % (rowtop + devtl.scaleH + (devtl.rowH / 2)) if data.do_one_initcall: if('ftrace' not in dev): continue cg = dev['ftrace'] large, stats = cgOverview(cg, 0.001) devstats[dev['id']]['fstat'] = stats for l in large: left = '%f' % (((l.time-t0)*100)/tTotal) width = '%f' % (l.length*100/tTotal) title = '%s (%0.3fms)' % (l.name, l.length * 1000.0) devtl.html += html_srccall.format(l.name, left, top, height, width, title, 'x%d'%num) num += 1 continue if('ftraces' not in dev): continue for cg in dev['ftraces']: left = '%f' % (((cg.start-t0)*100)/tTotal) width = '%f' % ((cg.end-cg.start)*100/tTotal) cglen = (cg.end - cg.start) * 1000.0 title = '%s (%0.3fms)' % (cg.name, cglen) cg.id = 'x%d' % num devtl.html += html_srccall.format(cg.name, left, top, height, width, title, dev['id']+cg.id) num += 1 csvfile.close() # draw the time scale, try to make the number of labels readable devtl.createTimeScale(t0, tMax, tTotal, 'boot') devtl.html += '</div>\n' # timeline is finished devtl.html += '</div>\n</div>\n' # draw a legend which describes the phases by color devtl.html += '<div class="legend">\n' pdelta = 20.0 pmargin = 36.0 for phase in data.phases: order = '%.2f' % ((data.dmesg[phase]['order'] * pdelta) + pmargin) devtl.html += devtl.html_legend.format(order, \ data.dmesg[phase]['color'], phase+'_mode', phase[0]) devtl.html += '</div>\n' hf = open(sysvals.htmlfile, 'w') # add the css extra = '\ .c1 {background:rgba(209,0,0,0.4);}\n\ .c2 {background:rgba(255,102,34,0.4);}\n\ .c3 {background:rgba(255,218,33,0.4);}\n\ .c4 {background:rgba(51,221,0,0.4);}\n\ .c5 {background:rgba(17,51,204,0.4);}\n\ .c6 {background:rgba(34,0,102,0.4);}\n\ .c7 {background:rgba(51,0,68,0.4);}\n\ .c8 {background:rgba(204,255,204,0.4);}\n\ .c9 {background:rgba(169,208,245,0.4);}\n\ .c10 {background:rgba(255,255,204,0.4);}\n\ .vt {transform:rotate(-60deg);transform-origin:0 0;}\n\ table.fstat {table-layout:fixed;padding:150px 15px 0 0;font-size:10px;column-width:30px;}\n\ .fstat th {width:55px;}\n\ .fstat td {text-align:left;width:35px;}\n\ .srccall {position:absolute;font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-radius:5px;border:1px solid black;background:linear-gradient(to bottom right,#CCC,#969696);}\n\ .srccall:hover {color:white;font-weight:bold;border:1px solid white;}\n' aslib.addCSS(hf, sysvals, 1, False, extra) # write the device timeline hf.write(devtl.html) # add boot specific html statinfo = 'var devstats = {\n' for n in sorted(devstats): statinfo += '\t"%s": [\n\t\t"%s",\n' % (n, devstats[n]['info']) if 'fstat' in devstats[n]: funcs = devstats[n]['fstat'] for f in sorted(funcs, key=funcs.get, reverse=True): if funcs[f][0] < 0.01 and len(funcs) > 10: break statinfo += '\t\t"%f|%s|%d",\n' % (funcs[f][0], f, funcs[f][1]) statinfo += '\t],\n' statinfo += '};\n' html = \ '<div id="devicedetailtitle"></div>\n'\ '<div id="devicedetail" style="display:none;">\n'\ '<div id="devicedetail0">\n' for p in data.phases: phase = data.dmesg[p] html += devtl.html_phaselet.format(p+'_mode', '0', '100', phase['color']) html += '</div>\n</div>\n'\ '<script type="text/javascript">\n'+statinfo+\ '</script>\n' hf.write(html) # add the callgraph html if(sysvals.usecallgraph): aslib.addCallgraphs(sysvals, hf, data) # add the test log as a hidden div if sysvals.testlog and sysvals.logmsg: hf.write('<div id="testlog" style="display:none;">\n'+sysvals.logmsg+'</div>\n') # add the dmesg log as a hidden div if sysvals.dmesglog: hf.write('<div id="dmesglog" style="display:none;">\n') for line in data.dmesgtext: line = line.replace('<', '<').replace('>', '>') hf.write(line) hf.write('</div>\n') # write the footer and close aslib.addScriptCode(hf, [data]) hf.write('</body>\n</html>\n') hf.close() return True