feat: add --cprofile flag for runtime profiling

Writes cProfile stats to a file on shutdown for performance analysis.
Enable in compose.yaml for container profiling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-21 16:54:29 +01:00
parent d13d090e8e
commit b8d8c22dc8
3 changed files with 9 additions and 1 deletions

1
.gitignore vendored
View File

@@ -15,6 +15,7 @@ build/
.pytest_cache/
.mypy_cache/
*.log
*.prof
# Personal config (keep example only)
config/bouncer.toml

View File

@@ -15,4 +15,4 @@ services:
volumes:
- ./src:/app/src:Z,ro
- ./config:/data:Z
command: ["-c", "/data/bouncer.toml", "-v"]
command: ["-c", "/data/bouncer.toml", "-v", "--cprofile", "/data/bouncer.prof"]

View File

@@ -25,6 +25,13 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
action="store_true",
help="enable debug logging",
)
parser.add_argument(
"--cprofile",
type=Path,
default=None,
metavar="PATH",
help="enable cProfile, write stats to PATH on shutdown",
)
parser.add_argument(
"--version",
action="version",