MCPcopy Create free account
hub / github.com/bhowiebkr/PyFlowGraph / analyze_performance_issues

Method analyze_performance_issues

testing/test_analyzer.py:334–365  ·  view source on GitHub ↗

Analyze test performance and identify bottlenecks.

(self, results_file: Path)

Source from the content-addressed store, hash-verified

332 return 'LOW'
333
334 def analyze_performance_issues(self, results_file: Path) -> List[PerformanceIssue]:
335 """Analyze test performance and identify bottlenecks."""
336 if not results_file.exists():
337 return []
338
339 try:
340 with open(results_file, 'r') as f:
341 data = json.load(f)
342 except json.JSONDecodeError:
343 return []
344
345 issues = []
346
347 for test in data.get('tests', []):
348 duration = test.get('duration', 0)
349
350 # Flag tests slower than 5 seconds (per CLAUDE.md requirement)
351 if duration > 5.0:
352 test_name = test['nodeid']
353 category = self._categorize_test(test_name)
354 bottleneck_type = self._identify_bottleneck_type(test_name, duration)
355 suggestion = self._get_optimization_suggestion(category, bottleneck_type, duration)
356
357 issues.append(PerformanceIssue(
358 test_name=test_name,
359 duration=duration,
360 category=category,
361 bottleneck_type=bottleneck_type,
362 optimization_suggestion=suggestion
363 ))
364
365 return sorted(issues, key=lambda x: x.duration, reverse=True)
366
367 def _categorize_test(self, test_name: str) -> str:
368 """Categorize test based on its name and path."""

Callers 1

analyzeMethod · 0.95

Calls 5

_categorize_testMethod · 0.95
PerformanceIssueClass · 0.85
loadMethod · 0.80

Tested by

no test coverage detected