diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dfd3ed5..1440fac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -166,7 +166,7 @@ performance_tests_dev: - pip install requests Pillow prettytable pyLibravatar dnspython py3dns script: - echo "Running performance tests against dev.libravatar.org..." - - python3 scripts/performance_tests.py --base-url $DEV_URL --concurrent-users 5 --output performance_dev.json + - python3 scripts/performance_tests.py --base-url $DEV_URL --concurrent-users 5 --avatar-threshold 2500 --output performance_dev.json artifacts: paths: - performance_dev.json diff --git a/scripts/performance_tests.py b/scripts/performance_tests.py index baaf1e5..b8c7c4d 100644 --- a/scripts/performance_tests.py +++ b/scripts/performance_tests.py @@ -831,7 +831,7 @@ class PerformanceTestRunner: return first_duration, second_duration - def run_all_tests(self) -> Optional[Dict[str, Any]]: + def run_all_tests(self, avatar_threshold: int = 1000) -> Optional[Dict[str, Any]]: """Run all performance tests""" print("Starting Libravatar Performance Tests") print("=" * 50) @@ -865,7 +865,7 @@ class PerformanceTestRunner: print(f"Performance tests completed in {total_duration:.2f}s") # Overall assessment - self.assess_overall_performance() + self.assess_overall_performance(avatar_threshold) return self.results @@ -928,7 +928,7 @@ class PerformanceTestRunner: "success_rate": len(successful_results) / len(results) if results else 0, } - def assess_overall_performance(self) -> bool: + def assess_overall_performance(self, avatar_threshold: int = 1000) -> bool: """Provide overall performance assessment""" print("\n=== OVERALL PERFORMANCE ASSESSMENT ===") @@ -937,8 +937,8 @@ class PerformanceTestRunner: # Check avatar generation if "avatar_generation" in self.results: avg_gen = self.results["avatar_generation"]["average_ms"] - if avg_gen > 1000: - warnings.append(f"Avatar generation is slow ({avg_gen:.0f}ms average)") + if avg_gen > avatar_threshold: + warnings.append(f"Avatar generation is slow ({avg_gen:.0f}ms average, threshold: {avatar_threshold}ms)") # Check concurrent load if "concurrent_load" in self.results: @@ -1000,6 +1000,12 @@ def main() -> Optional[Dict[str, Any]]: action="store_true", help="Force remote testing mode (auto-detected for non-localhost URLs)", ) + parser.add_argument( + "--avatar-threshold", + type=int, + default=1000, + help="Avatar generation threshold in ms (default: 1000ms, use 2500 for dev environments)", + ) args = parser.parse_args() @@ -1016,7 +1022,7 @@ def main() -> Optional[Dict[str, Any]]: remote_testing=remote_testing, ) - results = runner.run_all_tests() + results = runner.run_all_tests(args.avatar_threshold) if args.output and results: import json