Calculates heatmap for a module.
(self)
| 188 | } |
| 189 | |
| 190 | def _profile_module(self): |
| 191 | """Calculates heatmap for a module.""" |
| 192 | with open(self._run_object, 'r') as srcfile: |
| 193 | src_code = srcfile.read() |
| 194 | code = compile(src_code, self._run_object, 'exec') |
| 195 | try: |
| 196 | with _CodeHeatmapCalculator() as prof: |
| 197 | exec(code, self._globs, None) |
| 198 | except SystemExit: |
| 199 | pass |
| 200 | |
| 201 | heatmaps = [] |
| 202 | for filename, heatmap in prof.heatmap.items(): |
| 203 | if os.path.isfile(filename): |
| 204 | heatmaps.append( |
| 205 | self._format_heatmap( |
| 206 | filename, heatmap, prof.execution_count[filename])) |
| 207 | |
| 208 | run_time = sum(heatmap['runTime'] for heatmap in heatmaps) |
| 209 | return { |
| 210 | 'objectName': self._run_object, |
| 211 | 'runTime': run_time, |
| 212 | 'heatmaps': heatmaps |
| 213 | } |
| 214 | |
| 215 | def profile_module(self): |
| 216 | """Runs module profiler in a separate process.""" |
nothing calls this directly
no test coverage detected