Skip to content

Latest commit

 

History

History
144 lines (111 loc) · 4.76 KB

File metadata and controls

144 lines (111 loc) · 4.76 KB

Benchmarking Implementation Summary

What Was Added

I've successfully added comprehensive benchmarking capabilities to your Git Repository Manager to help identify why update_repository_tree_with_branch_filter is slow.

🔧 Core Benchmarking Features

1. Benchmark Decorator

@benchmark
def my_method(self):
    # Automatically timed when called
    pass

2. Advanced Benchmarking Options

@benchmark(print_args=True)  # Shows method arguments
def my_method_with_args(self, arg1, arg2):
    pass

3. Context Manager for Custom Timing

with time_operation("Custom operation name"):
    # Your code here
    pass

4. Manual Method Benchmarking

benchmark_method(obj, "method_name", arg1, arg2)

📊 Methods Now Being Benchmarked

I've added the @benchmark decorator to these key methods:

  1. update_repository_tree_with_branch_filter - The main slow method
  2. _repo_has_matching_branches - Checks each repo for matching branches
  3. _build_folder_structure - Builds folder hierarchy
  4. load_branches_if_needed - Loads branches when needed
  5. load_branches - Performs actual Git operations

🎮 UI Debug Menu

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

📈 Enhanced Performance Analysis

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

📝 Files Created

  1. BENCHMARKING.md - Comprehensive benchmarking guide
  2. benchmark_test.py - Simple demo/test of benchmarking features
  3. test_benchmarking.py - Unit tests for benchmarking functionality
  4. analyze_performance.py - Focused performance analysis tool

🚀 How to Use

Method 1: Run the Application

  1. Start the application normally
  2. Select a folder with Git repositories
  3. Set branch filters (user or message)
  4. Use Debug > Profile Branch Filtering to see detailed timing

Method 2: Use Test Scripts

python benchmark_test.py          # Demo application with benchmarking info
python test_benchmarking.py       # Test benchmarking functionality
python analyze_performance.py     # Focused performance analysis

Method 3: Enable/Disable Programmatically

from git_repository_manager import toggle_benchmarking
toggle_benchmarking()  # Disable benchmarking
toggle_benchmarking()  # Re-enable benchmarking

🔍 What to Look For

Console Output Patterns:

  • 🚀 BENCHMARK: Method execution times
  • ⚠️ Slow operations: Individual repos taking >100ms
  • 📊 Performance summaries: Breakdown of where time is spent
  • ⏱️ Custom timings: Specific operation measurements

Performance Red Flags:

  • Repository filtering taking >5 seconds for <100 repositories
  • Individual repositories taking >200ms to process
  • Branch loading taking >100ms per repository

🔧 Configuration

Global Settings

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

Runtime Toggle

  • Use Debug menu in UI
  • Call toggle_benchmarking() function
  • Modify BENCHMARKING_ENABLED variable

🎯 Expected Insights

This benchmarking will help you identify:

  1. Which repositories are slowest - Look for specific repo names in warnings
  2. Which operation is the bottleneck:
    • Repository filtering (checking branches)
    • Folder structure building
    • Tree UI updates
  3. Patterns in slow repositories:
    • Large repositories
    • Repositories with many branches
    • Network/remote repositories
    • Repositories with complex submodule structures

🚀 Next Steps

  1. Run with your data: Use the application with your repositories and branch filters
  2. Identify bottlenecks: Look for the patterns in console output
  3. Focus optimization: Use the insights to optimize specific slow areas
  4. 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!