Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parser = Format(args[0])
profile = parser.parse()
if options.output is None:
if PYTHON_3:
output = open(sys.stdout.fileno(), mode='wt', encoding='UTF-8', closefd=False)
else:
output = sys.stdout
else:
if PYTHON_3:
output = open(options.output, 'wt', encoding='UTF-8')
else:
output = open(options.output, 'wt')
dot = DotWriter(output)
dot.strip = options.strip
dot.wrap = options.wrap
labelNames = options.node_labels or defaultLabelNames
dot.show_function_events = [labels[l] for l in labelNames]
if options.show_samples:
dot.show_function_events.append(SAMPLES)
profile = profile
profile.prune(options.node_thres/100.0, options.edge_thres/100.0, options.filter_paths, options.color_nodes_by_selftime)
if options.root:
rootIds = profile.getFunctionIds(options.root)
if not rootIds:
sys.stderr.write('root node ' + options.root + ' not found (might already be pruned : try -e0 -n0 flags)\n')
sys.exit(1)
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 __rungprof2dot(self):
"""Runs gprof2dot which produces a full dot spec"""
nodeLimit = Settings().getProfilerSettings().nodeLimit
edgeLimit = Settings().getProfilerSettings().edgeLimit
with io.StringIO() as buf:
gprofParser = gprof2dot.PstatsParser(self.__dataFile)
profileData = gprofParser.parse()
profileData.prune(nodeLimit / 100.0, edgeLimit / 100.0, False, False)
dot = gprof2dot.DotWriter(buf)
dot.strip = False
dot.wrap = False
dot.graph(profileData, gprof2dot.TEMPERATURE_COLORMAP)
output = buf.getvalue()
return self.__postprocessFullDotSpec(output)
caller.add_call(call)
else:
call[SAMPLES2] += alloc.size
callee = caller
# compute derived data
profile.validate()
profile.find_cycles()
profile.ratio(TIME_RATIO, SAMPLES)
profile.call_ratios(SAMPLES2)
profile.integrate(TOTAL_TIME_RATIO, TIME_RATIO)
from gprof2dot import DotWriter, TEMPERATURE_COLORMAP
writer = DotWriter(open('memtrail.dot', 'wt'))
writer.strip = True
writer.wrap = True
profile.prune(0.5/100.0, 0.1/100.0)
writer.graph(profile, TEMPERATURE_COLORMAP)