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()
Beispiel #2
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)
Beispiel #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)
Beispiel #4
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
Beispiel #5
0
def _create_profile(source, get_filename=_temp_file_from_file_field):
    """
    Parse a profile from a django file field source.
    """
    with get_filename(source) as filename:
        return PstatsParser(filename).parse()