MCPcopy Create free account
hub / github.com/ActiveState/code / parse

Method parse

recipes/Python/578138_gprof2dotpy/recipe-578138.py:1007–1070  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1005 line = self.readline()
1006
1007 def parse(self):
1008 self.parse_cg()
1009 self.fp.close()
1010
1011 profile = Profile()
1012 profile[TIME] = 0.0
1013
1014 cycles = {}
1015 for index in self.cycles.keys():
1016 cycles[index] = Cycle()
1017
1018 for entry in self.functions.values():
1019 # populate the function
1020 function = Function(entry.index, entry.name)
1021 function[TIME] = entry.self
1022 if entry.called is not None:
1023 function.called = entry.called
1024 if entry.called_self is not None:
1025 call = Call(entry.index)
1026 call[CALLS] = entry.called_self
1027 function.called += entry.called_self
1028
1029 # populate the function calls
1030 for child in entry.children:
1031 call = Call(child.index)
1032
1033 assert child.called is not None
1034 call[CALLS] = child.called
1035
1036 if child.index not in self.functions:
1037 # NOTE: functions that were never called but were discovered by gprof's
1038 # static call graph analysis dont have a call graph entry so we need
1039 # to add them here
1040 missing = Function(child.index, child.name)
1041 function[TIME] = 0.0
1042 function.called = 0
1043 profile.add_function(missing)
1044
1045 function.add_call(call)
1046
1047 profile.add_function(function)
1048
1049 if entry.cycle is not None:
1050 try:
1051 cycle = cycles[entry.cycle]
1052 except KeyError:
1053 sys.stderr.write('warning: <cycle %u as a whole> entry missing\n' % entry.cycle)
1054 cycle = Cycle()
1055 cycles[entry.cycle] = cycle
1056 cycle.add_function(function)
1057
1058 profile[TIME] = profile[TIME] + function[TIME]
1059
1060 for cycle in cycles.values():
1061 profile.add_cycle(cycle)
1062
1063 # Compute derived events
1064 profile.validate()

Callers

nothing calls this directly

Calls 15

parse_cgMethod · 0.95
add_functionMethod · 0.95
add_callMethod · 0.95
add_functionMethod · 0.95
add_cycleMethod · 0.95
validateMethod · 0.95
ratioMethod · 0.95
call_ratiosMethod · 0.95
integrateMethod · 0.95
CycleClass · 0.85
CallClass · 0.85
ProfileClass · 0.70

Tested by

no test coverage detected