Skip to content

Commit a2e6138

Browse files
committed
GitRepositoryManager: A simple tool to manage multiple Git Repositories in one folder
0 parents  commit a2e6138

26 files changed

Lines changed: 4186 additions & 0 deletions

.gitignore

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
2+
app_data.json
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec.backup
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# poetry
101+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105+
#poetry.lock
106+
107+
# pdm
108+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109+
#pdm.lock
110+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111+
# in version control.
112+
# https://pdm.fming.dev/#use-with-ide
113+
.pdm.toml
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.venv
128+
env/
129+
venv/
130+
ENV/
131+
env.bak/
132+
venv.bak/
133+
134+
# Spyder project settings
135+
.spyderproject
136+
.spyproject
137+
138+
# Rope project settings
139+
.ropeproject
140+
141+
# mkdocs documentation
142+
/site
143+
144+
# mypy
145+
.mypy_cache/
146+
.dmypy.json
147+
dmypy.json
148+
149+
# Pyre type checker
150+
.pyre/
151+
152+
# pytype static type analyzer
153+
.pytype/
154+
155+
# Cython debug symbols
156+
cython_debug/
157+
158+
# PyCharm
159+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160+
# be added to the global gitignore or merged into this project gitignore. For IntelliJ Platform
161+
# plugin development:
162+
# https://github.com/JetBrains/intellij-community/blob/master/.gitignore
163+
.idea/
164+
165+
# Visual Studio Code
166+
.vscode/
167+
*.code-workspace
168+
169+
# Local History for Visual Studio Code
170+
.history/
171+
172+
# Built Visual Studio Code Extensions
173+
*.vsix
174+
175+
#########################
176+
# Project Specific Files
177+
#########################
178+
179+
# Application debug logs
180+
manager_debug.log*
181+
*.log
182+
183+
# Application data and settings (if you want to keep personal settings out of version control)
184+
# Uncomment the next line if app_data.json contains personal/sensitive data:
185+
# app_data.json
186+
187+
# PyInstaller build artifacts
188+
dist/
189+
build/
190+
*.spec.backup
191+
192+
# Application lock files
193+
git_repository_manager.lock
194+
*.lock
195+
196+
# Windows batch file outputs
197+
*.bat.log
198+
199+
# Temporary files
200+
temp/
201+
tmp/
202+
*.tmp
203+
*.temp
204+
205+
# OS specific files
206+
# macOS
207+
.DS_Store
208+
.DS_Store?
209+
._*
210+
.Spotlight-V100
211+
.Trashes
212+
ehthumbs.db
213+
Thumbs.db
214+
215+
# Windows
216+
Thumbs.db
217+
ehthumbs.db
218+
Desktop.ini
219+
$RECYCLE.BIN/
220+
*.cab
221+
*.msi
222+
*.msm
223+
*.msp
224+
*.lnk
225+
226+
# Linux
227+
*~
228+
229+
# Backup files
230+
*.bak
231+
*.backup
232+
*.old
233+
*.orig
234+
*.swp
235+
*.swo
236+
237+
# Runtime cache files
238+
.cache/
239+
cache/

BENCHMARKING.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Benchmarking Guide
2+
3+
## Overview
4+
The Git Repository Manager now includes comprehensive benchmarking capabilities to identify performance bottlenecks, especially in the `update_repository_tree_with_branch_filter` method.
5+
6+
## Features Added
7+
8+
### 1. Benchmark Decorator
9+
```python
10+
@benchmark
11+
def my_method(self):
12+
# Method will be automatically timed
13+
pass
14+
15+
@benchmark(print_args=True)
16+
def my_method_with_args(self, arg1, arg2):
17+
# Method will be timed and arguments will be shown
18+
pass
19+
```
20+
21+
### 2. Performance Monitoring Functions
22+
- `toggle_benchmarking()` - Enable/disable benchmarking globally
23+
- `time_operation(name)` - Context manager for timing specific operations
24+
25+
### 3. UI Debug Menu
26+
Access via **Debug** menu in the application:
27+
- **Toggle Benchmarking** - Turn performance monitoring on/off
28+
- **Profile Repository Loading** - Analyze repository scanning performance
29+
- **Profile Branch Filtering** - Analyze branch filtering performance
30+
31+
## Benchmarked Methods
32+
33+
The following methods are automatically benchmarked:
34+
35+
1. **`update_repository_tree_with_branch_filter`** - The main slow method
36+
2. **`_repo_has_matching_branches`** - Checks each repository for matching branches
37+
3. **`_build_folder_structure`** - Builds the hierarchical folder structure
38+
4. **`load_branches_if_needed`** - Loads branch data when needed
39+
5. **`load_branches`** - Performs actual Git branch loading
40+
41+
## Console Output
42+
43+
### Benchmark Messages
44+
- 🚀 `BENCHMARK: ClassName.method_name took 0.1234 seconds`
45+
-`BENCHMARK: ClassName.method_name failed after 0.1234 seconds`
46+
47+
### Detailed Performance Analysis
48+
When `update_repository_tree_with_branch_filter` runs, you'll see:
49+
- 🔍 `Filtering X repositories...`
50+
- ⚠️ `Repo repo_name took 0.123s` (for slow repositories)
51+
- 📊 `Repository filtering took 0.123s, found X matching repos`
52+
- 🏗️ `Folder structure building took 0.123s`
53+
- 🌳 `Tree building took 0.123s`
54+
55+
## Usage Examples
56+
57+
### 1. Test Performance
58+
```bash
59+
python benchmark_test.py
60+
```
61+
62+
### 2. Disable Benchmarking Programmatically
63+
```python
64+
from git_repository_manager import BENCHMARKING_ENABLED
65+
BENCHMARKING_ENABLED = False
66+
```
67+
68+
### 3. Time Custom Operations
69+
```python
70+
from git_repository_manager import time_operation
71+
72+
with time_operation("My custom operation"):
73+
# Your code here
74+
pass
75+
```
76+
77+
## Performance Analysis Tips
78+
79+
1. **Look for patterns**: Which repositories consistently take longer?
80+
2. **Check branch counts**: Repositories with many branches may be slower
81+
3. **Network repositories**: Remote repositories may have network latency
82+
4. **Submodules**: These add extra overhead during filtering
83+
84+
## Expected Performance
85+
86+
**Normal performance** (per repository):
87+
- Branch loading: < 50ms
88+
- Branch filtering: < 10ms
89+
90+
**Concerning performance** (investigate if you see):
91+
- Branch loading: > 200ms
92+
- Branch filtering: > 100ms
93+
- Total filtering time: > 5 seconds for < 100 repositories
94+
95+
## Configuration
96+
97+
### Global Settings
98+
```python
99+
# At the top of git_repository_manager.py
100+
BENCHMARKING_ENABLED = True # Change to False to disable all benchmarking
101+
```
102+
103+
### Runtime Toggle
104+
Use the Debug menu or call `toggle_benchmarking()` to enable/disable during runtime.
105+
106+
## Troubleshooting
107+
108+
If you see consistently slow performance:
109+
110+
1. **Check repository count**: Too many repositories can slow filtering
111+
2. **Check branch counts**: Use `git branch -a | wc -l` in slow repositories
112+
3. **Check network connectivity**: Network repositories may have latency
113+
4. **Check Git repository health**: Run `git fsck` in problematic repositories
114+
5. **Check disk I/O**: SSD vs HDD can impact Git operations significantly
115+
116+
## Sample Output
117+
118+
```
119+
🚀 BENCHMARK: GitRepositoryManager.update_repository_tree_with_branch_filter took 2.1234 seconds
120+
🔍 Filtering 45 repositories...
121+
⚠️ Repo large-project took 0.156s
122+
⚠️ Submodule complex-submodule took 0.203s
123+
📊 Repository filtering took 1.234s, found 12 matching repos
124+
🏗️ Folder structure building took 0.456s
125+
🌳 Tree building took 0.789s
126+
🚀 BENCHMARK: GitRepositoryManager._build_folder_structure took 0.4567 seconds
127+
```
128+
129+
This shows that repository filtering is the bottleneck, with two specific repositories being slow.

0 commit comments

Comments
 (0)