The Git Repository Manager now includes comprehensive benchmarking capabilities to identify performance bottlenecks, especially in the update_repository_tree_with_branch_filter method.
@benchmark
def my_method(self):
# Method will be automatically timed
pass
@benchmark(print_args=True)
def my_method_with_args(self, arg1, arg2):
# Method will be timed and arguments will be shown
passtoggle_benchmarking()- Enable/disable benchmarking globallytime_operation(name)- Context manager for timing specific operations
Access via Debug menu in the application:
- Toggle Benchmarking - Turn performance monitoring on/off
- Profile Repository Loading - Analyze repository scanning performance
- Profile Branch Filtering - Analyze branch filtering performance
The following methods are automatically benchmarked:
update_repository_tree_with_branch_filter- The main slow method_repo_has_matching_branches- Checks each repository for matching branches_build_folder_structure- Builds the hierarchical folder structureload_branches_if_needed- Loads branch data when neededload_branches- Performs actual Git branch loading
- 🚀
BENCHMARK: ClassName.method_name took 0.1234 seconds - ❌
BENCHMARK: ClassName.method_name failed after 0.1234 seconds
When update_repository_tree_with_branch_filter runs, you'll see:
- 🔍
Filtering X repositories... ⚠️ Repo repo_name took 0.123s(for slow repositories)- 📊
Repository filtering took 0.123s, found X matching repos - 🏗️
Folder structure building took 0.123s - 🌳
Tree building took 0.123s
python benchmark_test.pyfrom git_repository_manager import BENCHMARKING_ENABLED
BENCHMARKING_ENABLED = Falsefrom git_repository_manager import time_operation
with time_operation("My custom operation"):
# Your code here
pass- Look for patterns: Which repositories consistently take longer?
- Check branch counts: Repositories with many branches may be slower
- Network repositories: Remote repositories may have network latency
- Submodules: These add extra overhead during filtering
Normal performance (per repository):
- Branch loading: < 50ms
- Branch filtering: < 10ms
Concerning performance (investigate if you see):
- Branch loading: > 200ms
- Branch filtering: > 100ms
- Total filtering time: > 5 seconds for < 100 repositories
# At the top of git_repository_manager.py
BENCHMARKING_ENABLED = True # Change to False to disable all benchmarkingUse the Debug menu or call toggle_benchmarking() to enable/disable during runtime.
If you see consistently slow performance:
- Check repository count: Too many repositories can slow filtering
- Check branch counts: Use
git branch -a | wc -lin slow repositories - Check network connectivity: Network repositories may have latency
- Check Git repository health: Run
git fsckin problematic repositories - Check disk I/O: SSD vs HDD can impact Git operations significantly
🚀 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
🚀 BENCHMARK: GitRepositoryManager._build_folder_structure took 0.4567 seconds
This shows that repository filtering is the bottleneck, with two specific repositories being slow.