MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / render_table

Method render_table

src/pyspector/stats.py:207–313  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

205
206
207 def render_table(self) -> str:
208 lines: List[str] = []
209
210 lines.append(_top())
211 lines.append(_banner("PYSPECTOR SCAN STATISTICS"))
212 lines.append(_sep_top()) # first column split
213
214 lines.append(_section_title("PERFORMANCE"))
215 lines.append(_sep())
216
217 elapsed_str = f"{self.elapsed:.2f}s"
218 lines.append(_row("Total scan time", elapsed_str))
219 lines.append(_row("Lines of code scanned", f"{self.total_loc:,}"))
220 lines.append(_row("Throughput", f"{self.loc_per_sec:,.0f} LoC/sec"))
221 lines.append(_row("Python files scanned", str(self.files_scanned)))
222 lines.append(_row("Files skipped", str(self.files_skipped)))
223 lines.append(_row("Parse errors", str(self.parse_errors)))
224
225 lines.append(_sep())
226 lines.append(_section_title("RESOURCE USAGE"))
227 lines.append(_sep())
228
229 if self._psutil_ok:
230 mem_str = (
231 f"{self.peak_memory_mb:.0f} MB"
232 if self.peak_memory_mb is not None
233 else "n/a"
234 )
235 lines.append(_row("Peak memory usage", mem_str))
236
237 if self.avg_cpu_percent is not None and self.cpu_cores_logical:
238 cores_used = self.avg_cpu_percent / 100
239 lines.append(_row(
240 "CPU cores utilized",
241 f"{cores_used:.1f} / {self.cpu_cores_logical} logical cores",
242 ))
243 lines.append(_row(
244 "Avg CPU utilization",
245 f"{self.avg_cpu_percent:.0f}% (multi-core, can exceed 100%)",
246 ))
247 else:
248 lines.append(_row("CPU usage", "scan completed too quickly to sample"))
249 else:
250 lines.append(_row(
251 "Resource tracking",
252 "run pip install psutil to enable this section",
253 ))
254
255 lines.append(_sep())
256 lines.append(_section_title("ANALYSIS BREAKDOWN"))
257 lines.append(_sep())
258
259 lines.append(_row("Rules evaluated", str(self.rules_count)))
260 lines.append(_row("Regex engine findings", str(self.regex_findings)))
261 lines.append(_row("AST engine findings", str(self.ast_findings)))
262 lines.append(_row("Taint engine findings", str(self.taint_findings)))
263 lines.append(_row("Severity-filtered out", str(self.severity_filtered)))
264 lines.append(_row("Baseline-ignored", str(self.baseline_ignored)))

Callers 1

_execute_scanFunction · 0.95

Calls 7

_topFunction · 0.85
_bannerFunction · 0.85
_sep_topFunction · 0.85
_section_titleFunction · 0.85
_sepFunction · 0.85
_rowFunction · 0.85
_botFunction · 0.85

Tested by

no test coverage detected