def convert_to_dot(prof_string, prof_format):
    """Main program."""

    output = StringIO()
    theme = themes['color']
    total_method = 'callratios'
    node_thresh = 0.5
    edge_thresh = 0.1

    # for Format in formats.values():
    # try: 
    # if Format.multipleInput:
    #     continue

    Format = formats[prof_format]

    parser = Format(StringIO(prof_string))
    profile = parser.parse()

    dot = DotWriter(output)
    dot.strip = True
    dot.wrap = True
    profile.prune(node_thresh / 100.0, edge_thresh / 100.0)

    dot.graph(profile, theme)

        # except Exception as e:
        #     print e
        #     continue
    
    return output.getvalue()
def generate_diagram_spec(stats_file):
    output = StringIO()
    parser = PstatsParser(stats_file)
    profile = parser.parse()
    dot = DotWriter(output)
    profile.prune(0.005, 0.001)
    theme = TEMPERATURE_COLORMAP
    theme.skew = 1.0
    dot.graph(profile, theme)
    return output.getvalue()
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
def make_dot(name):
    prof_name = get_prof_name(name)
    dot_name = get_dot_name(name)
    if not os.path.exists(prof_name):
        return False
    parser = PstatsParser(prof_name)
    profile = parser.parse()
    with open(dot_name, 'wt') as dotfile:
        dotwriter = DotWriter(dotfile)
        profile.prune(0.005, 0.001)
        dotwriter.graph(profile, TEMPERATURE_COLORMAP)
    return True
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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()