一套完整的性能测试解决方案,用于测试API、Web服务和应用程序的性能表现。
A comprehensive performance testing solution for testing APIs, web services, and application performance.
bash
# 基础负载测试 | Basic load test
python scripts/perf_tester.py load --url https://api.example.com/users --concurrent 100 --duration 60
# 压力测试 | Stress test
python scripts/perf_tester.py stress --url https://api.example.com/search --start 10 --max 1000 --step 50
# 基准对比测试 | Benchmark test
python scripts/perf_tester.py benchmark --config benchmark.yaml
python
from performance_testing_toolkit import LoadTester, StressTester
# 负载测试 | Load test
tester = LoadTester(url="https://api.example.com/api", concurrent=100)
results = tester.run(duration=60)
print(f"平均响应时间: {results.avg_response_time}ms")
# 压力测试 | Stress test
stress = StressTester(url="https://api.example.com/api")
stress.run(start_concurrent=10, max_concurrent=1000, step=50)
参数说明默认值--url目标URL必填--concurrent并发用户数10--duration测试持续时间(秒)60--methodHTTP方法GET--headers请求头(JSON格式){}--output报告输出格式html
详见 examples/ 目录。
bash
python -m pytest tests/ -v