I've successfully added comprehensive benchmarking capabilities to your Git Repository Manager to help identify why update_repository_tree_with_branch_filter is slow.
@benchmark
def my_method(self):
# Automatically timed when called
pass@benchmark(print_args=True) # Shows method arguments
def my_method_with_args(self, arg1, arg2):
passwith time_operation("Custom operation name"):
# Your code here
passbenchmark_method(obj, "method_name", arg1, arg2)I've added the @benchmark decorator to these key methods:
update_repository_tree_with_branch_filter- The main slow method_repo_has_matching_branches- Checks each repo for matching branches_build_folder_structure- Builds folder hierarchyload_branches_if_needed- Loads branches when neededload_branches- Performs actual Git operations
Added a new Debug menu with options:
- Toggle Benchmarking - Enable/disable performance monitoring
- Profile Repository Loading - Test repository scanning performance
- Profile Branch Filtering - Test branch filtering performance
The update_repository_tree_with_branch_filter method now provides detailed timing breakdown:
🚀 BENCHMARK: GitRepositoryManager.update_repository_tree_with_branch_filter took 2.1234 seconds
🔍 Filtering 45 repositories...
⚠️ Repo large-project took 0.156s
⚠️ Submodule complex-submodule took 0.203s
📊 Repository filtering took 1.234s, found 12 matching repos
🏗️ Folder structure building took 0.456s
🌳 Tree building took 0.789s
BENCHMARKING.md- Comprehensive benchmarking guidebenchmark_test.py- Simple demo/test of benchmarking featurestest_benchmarking.py- Unit tests for benchmarking functionalityanalyze_performance.py- Focused performance analysis tool
- Start the application normally
- Select a folder with Git repositories
- Set branch filters (user or message)
- Use Debug > Profile Branch Filtering to see detailed timing
python benchmark_test.py # Demo application with benchmarking info
python test_benchmarking.py # Test benchmarking functionality
python analyze_performance.py # Focused performance analysisfrom git_repository_manager import toggle_benchmarking
toggle_benchmarking() # Disable benchmarking
toggle_benchmarking() # Re-enable benchmarking- 🚀 BENCHMARK: Method execution times
⚠️ Slow operations: Individual repos taking >100ms- 📊 Performance summaries: Breakdown of where time is spent
- ⏱️ Custom timings: Specific operation measurements
- Repository filtering taking >5 seconds for <100 repositories
- Individual repositories taking >200ms to process
- Branch loading taking >100ms per repository
# At top of git_repository_manager.py
BENCHMARKING_ENABLED = True # Set to False to disable all benchmarking- Use Debug menu in UI
- Call
toggle_benchmarking()function - Modify
BENCHMARKING_ENABLEDvariable
This benchmarking will help you identify:
- Which repositories are slowest - Look for specific repo names in warnings
- Which operation is the bottleneck:
- Repository filtering (checking branches)
- Folder structure building
- Tree UI updates
- Patterns in slow repositories:
- Large repositories
- Repositories with many branches
- Network/remote repositories
- Repositories with complex submodule structures
- Run with your data: Use the application with your repositories and branch filters
- Identify bottlenecks: Look for the patterns in console output
- Focus optimization: Use the insights to optimize specific slow areas
- Compare before/after: Use benchmarking to measure improvement after optimization
The benchmarking system is now ready to help you identify exactly why update_repository_tree_with_branch_filter is slow and where to focus optimization efforts!