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
| # DX评估指标
class DXMetrics:
"""开发者体验指标"""
dimensions = {
"ONBOARDING_TIME": {
"description": "新开发者上手时间",
"target": "< 1天",
"weight": 0.15
},
"BUILD_TIME": {
"description": "构建时间",
"target": "< 5分钟",
"weight": 0.2
},
"DEBUG_TIME": {
"description": "问题定位时间",
"target": "< 30分钟",
"weight": 0.2
},
"DEPLOY_TIME": {
"description": "部署时间",
"target": "< 10分钟",
"weight": 0.15
},
"DOC_COMPLETENESS": {
"description": "文档完整性",
"target": "> 80%",
"weight": 0.15
},
"TOOL_USABILITY": {
"description": "工具易用性",
"target": "> 4/5",
"weight": 0.15
}
}
def calculate_dx_score(self, measurements):
"""计算DX总分"""
total_score = 0
for metric, value in measurements.items():
target = self.dimensions[metric]['target']
weight = self.dimensions[metric]['weight']
# 计算得分
if isinstance(target, str) and target.startswith('<'):
target_value = float(target[1:])
score = min(1.0, target_value / value) if value > 0 else 0
elif isinstance(target, str) and target.startswith('>'):
target_value = float(target[1:])
score = min(1.0, value / target_value) if value > 0 else 0
else:
score = 1.0 if value else 0
total_score += score * weight
return total_score
|