def _create_dot(profile, cutoff): """ Create a dot file from pstats data stored in a django file field. """ node_cutoff = cutoff / 100.0 edge_cutoff = 0.1 / 100.0 profile.prune(node_cutoff, edge_cutoff, [], False) with closing(StringIO()) as fp: DotWriter(fp).graph(profile, COLOR_MAP) return fp.getvalue()
def __prof2dot(self, prof_path, dot_path): """Generate dot file from pstat profile if it does not already exist""" if not os.path.isfile(dot_path): parser = PstatsParser(prof_path) profile = parser.parse() with open(dot_path, 'wt') as dotfile: dotwriter = DotWriter(dotfile) profile.prune(0.005, 0.001) dotwriter.graph(profile, TEMPERATURE_COLORMAP)
def main(): parser = optparse.OptionParser( usage="\n\t%prog [options] [file] ...", version="%%prog %s" % __version__) parser.add_option( '-a', '--align', metavar='NUMBER', type="int", dest="align", default=16, help="section alignment") parser.add_option( '-m', '--map', metavar='FILE', type="string", dest="map", help="map file") parser.add_option( '-b', '--base', metavar='FILE', type="string", dest="base", help="base addr") parser.add_option( '-n', '--node-thres', metavar='PERCENTAGE', type="float", dest="node_thres", default=0.5, help="eliminate nodes below this threshold [default: %default]") parser.add_option( '-e', '--edge-thres', metavar='PERCENTAGE', type="float", dest="edge_thres", default=0.1, help="eliminate edges below this threshold [default: %default]") parser.add_option( '-v', '--verbose', action="count", dest="verbose", default=0, help="verbose output") global options (options, args) = parser.parse_args(sys.argv[1:]) reader = Reader() if options.base is not None: reader.base_addr = int(options.base, 16) if options.map is not None: reader.read_map(options.map) for arg in args: profile = reader.read_data(arg) profile.prune(options.node_thres/100.0, options.edge_thres/100.0) output = sys.stdout dot = DotWriter(output) colormap = TEMPERATURE_COLORMAP dot.graph(profile, colormap)