Skip to content

Latest commit

 

History

History
129 lines (98 loc) · 4.23 KB

File metadata and controls

129 lines (98 loc) · 4.23 KB

Benchmarking Guide

Overview

The Git Repository Manager now includes comprehensive benchmarking capabilities to identify performance bottlenecks, especially in the update_repository_tree_with_branch_filter method.

Features Added

1. Benchmark Decorator

@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
    pass

2. Performance Monitoring Functions

  • toggle_benchmarking() - Enable/disable benchmarking globally
  • time_operation(name) - Context manager for timing specific operations

3. UI Debug Menu

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

Benchmarked Methods

The following methods are automatically benchmarked:

  1. update_repository_tree_with_branch_filter - The main slow method
  2. _repo_has_matching_branches - Checks each repository for matching branches
  3. _build_folder_structure - Builds the hierarchical folder structure
  4. load_branches_if_needed - Loads branch data when needed
  5. load_branches - Performs actual Git branch loading

Console Output

Benchmark Messages

  • 🚀 BENCHMARK: ClassName.method_name took 0.1234 seconds
  • BENCHMARK: ClassName.method_name failed after 0.1234 seconds

Detailed Performance Analysis

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

Usage Examples

1. Test Performance

python benchmark_test.py

2. Disable Benchmarking Programmatically

from git_repository_manager import BENCHMARKING_ENABLED
BENCHMARKING_ENABLED = False

3. Time Custom Operations

from git_repository_manager import time_operation

with time_operation("My custom operation"):
    # Your code here
    pass

Performance Analysis Tips

  1. Look for patterns: Which repositories consistently take longer?
  2. Check branch counts: Repositories with many branches may be slower
  3. Network repositories: Remote repositories may have network latency
  4. Submodules: These add extra overhead during filtering

Expected Performance

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

Configuration

Global Settings

# At the top of git_repository_manager.py
BENCHMARKING_ENABLED = True  # Change to False to disable all benchmarking

Runtime Toggle

Use the Debug menu or call toggle_benchmarking() to enable/disable during runtime.

Troubleshooting

If you see consistently slow performance:

  1. Check repository count: Too many repositories can slow filtering
  2. Check branch counts: Use git branch -a | wc -l in slow repositories
  3. Check network connectivity: Network repositories may have latency
  4. Check Git repository health: Run git fsck in problematic repositories
  5. Check disk I/O: SSD vs HDD can impact Git operations significantly

Sample Output

🚀 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.