-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquick_test.sh
More file actions
executable file
·91 lines (80 loc) · 2.32 KB
/
quick_test.sh
File metadata and controls
executable file
·91 lines (80 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# 快速测试脚本 - 验证工具是否正常工作
echo "======================================"
echo " 快速测试 - 验证工具功能"
echo "======================================"
echo ""
# 创建测试数据
echo "创建模拟测试数据..."
python3 << 'EOF'
import json
from datetime import datetime, timedelta
# 创建模拟测试结果
results = []
base_time = datetime.now()
for i in range(5):
result = {
"test_index": i + 1,
"start_time": (base_time + timedelta(minutes=i*30)).strftime('%Y-%m-%d %H:%M:%S'),
"end_time": (base_time + timedelta(minutes=i*30, seconds=120)).strftime('%Y-%m-%d %H:%M:%S'),
"metrics": [
{
"concurrency": 10,
"rate": "INF",
"rps": 0.07 + i * 0.01,
"avg_latency": 45.0 + i * 2.0,
"p99_latency": 150.0 + i * 5.0,
"avg_ttft": 1.4 + i * 0.1,
"p99_ttft": 2.5 + i * 0.2,
"avg_tpot": 0.024,
"p99_tpot": 0.029,
"gen_toks": 120.0 + i * 5.0,
"success_rate": 100.0
}
],
"success": True,
"error_message": ""
}
results.append(result)
data = {
"config": {
"api": "openai",
"url": "https://test.example.com",
"model": "test-model",
"parallel": 8,
"number": 50
},
"test_time": datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
"total_tests": 5,
"results": results
}
with open('test_results.json', 'w') as f:
json.dump(data, f, indent=2)
print("模拟测试数据已创建: test_results.json")
EOF
# 生成报告
echo ""
echo "生成 HTML 报告..."
python3 generate_report.py --json-file test_results.json --output test_report.html
if [ $? -eq 0 ]; then
echo ""
echo "✅ 测试成功!"
echo "报告已生成: test_report.html"
echo ""
# 询问是否打开报告
read -p "是否打开报告? (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if command -v open &> /dev/null; then
open test_report.html
elif command -v xdg-open &> /dev/null; then
xdg-open test_report.html
else
echo "请手动打开 test_report.html"
fi
fi
else
echo ""
echo "❌ 测试失败"
exit 1
fi