# 性能测试脚本 ## 测试目标 使用 Locust 对后端接口和前端关键页面进行并发访问测试,验证系统在课程实践规模下的响应稳定性。 ## 测试脚本 | 脚本 | 目标 | 默认 Host | |---|---|---| | `locustfile_backend.py` | 后端接口性能测试 | `http://localhost:3000` | | `locustfile_frontend.py` | 前端页面性能测试 | `http://127.0.0.1:4301` | ## 运行命令 安装依赖: ```powershell cd E:\软测\ServicePilot\tests\performance_tests pip install -r requirements.txt ``` 后端性能测试: ```powershell powershell -ExecutionPolicy Bypass -File .\run_backend_performance.ps1 ``` 前端性能测试: ```powershell powershell -ExecutionPolicy Bypass -File .\run_frontend_performance.ps1 ``` ## 验收标准 | 指标 | 标准 | |---|---| | 查询类平均响应时间 | < 500ms | | 查询类 P95 | < 1000ms | | 错误率 | < 1% | | 服务稳定性 | 压测期间不崩溃 | ## 输出证据 ```text tests/performance_tests/reports/backend-performance-report.html tests/performance_tests/reports/backend-performance_*.csv tests/performance_tests/reports/frontend-performance-report.html tests/performance_tests/reports/frontend-performance_*.csv ``` 如果未安装 Locust,运行脚本会生成 `reports/*_performance_pending.txt`,用于说明未执行原因和补跑命令。