MCPcopy
hub / github.com/nvdv/vprof / _skip_lines

Method _skip_lines

vprof/code_heatmap.py:132–148  ·  view source on GitHub ↗

Skips lines in src_code specified by a skip map.

(src_code, skip_map)

Source from the content-addressed store, hash-verified

130
131 @staticmethod
132 def _skip_lines(src_code, skip_map):
133 """Skips lines in src_code specified by a skip map."""
134 if not skip_map:
135 return [['line', j + 1, l] for j, l in enumerate(src_code)]
136 code_with_skips, i = [], 0
137 for line, length in skip_map:
138 code_with_skips.extend(
139 ['line', i + j + 1, l] for j, l in enumerate(src_code[i:line]))
140 if (code_with_skips
141 and code_with_skips[-1][0] == 'skip'): # Merge skips.
142 code_with_skips[-1][1] += length
143 else:
144 code_with_skips.append(['skip', length])
145 i = line + length
146 code_with_skips.extend(
147 ['line', i + j + 1, l] for j, l in enumerate(src_code[i:]))
148 return code_with_skips
149
150 def _profile_package(self):
151 """Calculates heatmap for a package."""

Callers 2

_format_heatmapMethod · 0.95
testSkipLinesMethod · 0.80

Calls

no outgoing calls

Tested by 1

testSkipLinesMethod · 0.64