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

Method parse_row

recipes/Python/578138_gprof2dotpy/recipe-578138.py:2018–2059  ·  view source on GitHub ↗
(self, row)

Source from the content-addressed store, hash-verified

2016 self.column[name] = column
2017
2018 def parse_row(self, row):
2019 fields = {}
2020 for name, column in self.column.items():
2021 value = row[column]
2022 for factory in int, float:
2023 try:
2024 value = factory(value)
2025 except ValueError:
2026 pass
2027 else:
2028 break
2029 fields[name] = value
2030
2031 process = fields['Process Name']
2032 symbol = fields['Module'] + '!' + fields['Function']
2033 weight = fields['Weight']
2034 count = fields['Count']
2035
2036 function = self.get_function(process, symbol)
2037 function[SAMPLES] += weight * count
2038 self.profile[SAMPLES] += weight * count
2039
2040 stack = fields['Stack']
2041 if stack != '?':
2042 stack = stack.split('/')
2043 assert stack[0] == '[Root]'
2044 if stack[-1] != symbol:
2045 # XXX: some cases the sampled function does not appear in the stack
2046 stack.append(symbol)
2047 caller = None
2048 for symbol in stack[1:]:
2049 callee = self.get_function(process, symbol)
2050 if caller is not None:
2051 try:
2052 call = caller.calls[callee.id]
2053 except KeyError:
2054 call = Call(callee.id)
2055 call[SAMPLES2] = count
2056 caller.add_call(call)
2057 else:
2058 call[SAMPLES2] += count
2059 caller = callee
2060
2061 def get_function(self, process, symbol):
2062 function_id = process + '!' + symbol

Callers 1

parseMethod · 0.95

Calls 7

get_functionMethod · 0.95
CallClass · 0.85
add_callMethod · 0.80
factoryFunction · 0.50
itemsMethod · 0.45
splitMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected