-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
236 lines (225 loc) · 9.62 KB
/
index.html
File metadata and controls
236 lines (225 loc) · 9.62 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Web 性能报告 | Hans362 's Lab</title>
<link rel="shortcut icon" type="image/ico"
href="https://cdn.jsdelivr.net/gh/hans362/image-hosting@master/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32"
href="https://cdn.jsdelivr.net/gh/hans362/image-hosting@master/favicon-32x32.png">
<meta name="format-detection" content="telephone=no">
<meta name="description" itemprop="description" content="Hans362 的博客性能报告">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@latest/dist/semantic.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/suka.css@0.1.2">
<!--<script src="//cdn.jsdelivr.net/npm/eruda"></script>
<script>eruda.init();</script>-->
<style>
.item-title {
color: #adadad
}
.ui.table tr td,
.ui.table,
.ui.table tbody {
border: none;
}
.ui.table tr td {
padding: .3rem;
line-height: 1.2rem;
}
.ui.statistic>.value, .ui.statistics .statistic>.value {
text-transform: none;
}
.ui.four.statistics .statistic {
margin: 0 0 2.4em;
}
</style>
<!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3"></script><script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script><![endif]-->
<meta property="og:title" content="Web 性能报告 | Hans362 's Lab">
<meta property="og:type" content="Website">
<meta property="og:url" content="https://lab.hans362.cn/webpf">
<meta property="og:description" content="Hans362 的博客性能报告">
<meta name="twitter:card" content="summary">
</head>
<body class="sk-p-4 sk-pt-8 sk-pb-6">
<h1 class="ui center aligned header">
<i id="icon" class="server icon" data-position="left center" style="color: #4b5cc4;"></i>
Web 性能报告
</h1>
<h2 class="ui horizontal divider header"><i class="info icon"></i> 说明信息 </h2>
<div class="ui container text">
该报告由 Hans362 's Lab 基于 Hans362 's Blog 的性能表现生成,各项指标通过 GTMetrix Restful API v1 获取,每日自动更新。
</div>
<h2 class="ui horizontal divider header"><i class="clipboard check icon"></i> 综合得分 </h2>
<div class="ui container sk-pt-4">
<div class="ui two large statistics">
<div class="statistic huge" id="yslowc">
<div class="value" id="yslow">0</div>
<div class="label">YSLOW 得分 </div>
</div>
<div class="statistic huge" id="pgsc">
<div class="value" id="pgs">0</div>
<div class="label">PAGESPEED 得分 </div>
</div>
</div>
</div>
<h2 class="ui horizontal divider header"><i class="bar chart icon"></i> 详细报告 </h2>
<div class="ui container sk-pt-4">
<div class="ui four small statistics">
<div class="large statistic">
<div class="value" id="fcp">
0
</div>
<div class="label">FCP 用时 </div>
</div>
<div class="large statistic">
<div class="value" id="fp">
0
</div>
<div class="label">FP 用时 </div>
</div>
<div class="large statistic">
<div class="value" id="dom">
0
</div>
<div class="label">DOM 加载用时 </div>
</div>
<div class="large statistic">
<div class="value" id="domi">
0
</div>
<div class="label">DOM 交互用时 </div>
</div>
<div class="large statistic">
<div class="value" id="spi">
0
</div>
<div class="label">首屏展现用时 </div>
</div>
<div class="large statistic blue">
<div class="value" id="pe">
0
</div>
<div class="label">页面元素数量 </div>
</div>
<div class="large statistic blue">
<div class="value" id="pgb">
0
</div>
<div class="label">页面字节数 </div>
</div>
<div class="large statistic">
<div class="value" id="pgt">
0
</div>
<div class="label">页面加载用时 </div>
</div>
<div class="large statistic blue">
<div class="value" id="hb">
0
</div>
<div class="label">HTML 字节数 </div>
</div>
<div class="large statistic">
<div class="value" id="hl">
0
</div>
<div class="label">HTML 加载用时 </div>
</div>
<div class="large statistic">
<div class="value" id="bt">
0
</div>
<div class="label">后端用时 </div>
</div>
<div class="large statistic">
<div class="value" id="cnt">
0
</div>
<div class="label">连接用时 </div>
</div>
<div class="large statistic">
<div class="value" id="ol">
0
</div>
<div class="label">加载用时 </div>
</div>
<div class="large statistic">
<div class="value" id="fl">
0
</div>
<div class="label">完整加载用时 </div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@latest/dist/semantic.min.js"></script>
<script type="text/javascript">
function toThousands(num) {
return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
}
function toColor(num, threshold, item) {
var colorList = ['green','yellow','orange','red'];
var flag = 0;
for (var i=0; i<=2; i++) {
if (num <= threshold[i]) {
$(item).parent().addClass(colorList[i]);
flag = 1;
}
}
if (flag == 0) {
$(item).parent().addClass(colorList[3]);
}
}
var ctJson = "./ct.json?" + new Date().getTime() + Math.random();
$.getJSON(ctJson, function (data) {
$("#ol").text(toThousands(data.results.onload_time)+'ms');
toColor(data.results.onload_time,[1000,2000,3000],"#ol");
$("#fcp").text(toThousands(data.results.first_contentful_paint_time)+'ms');
toColor(data.results.first_contentful_paint_time,[1000,2000,3000],"#fcp");
$("#pe").text(toThousands(data.results.page_elements));
$("#fp").text(toThousands(data.results.first_paint_time)+'ms');
toColor(data.results.first_paint_time,[1000,2000,3000],"#fp");
$("#dom").text(toThousands(data.results.dom_content_loaded_time)+'ms');
toColor(data.results.dom_content_loaded_time,[1000,2000,3000],"#dom");
$("#domi").text(toThousands(data.results.dom_interactive_time)+'ms');
toColor(data.results.dom_interactive_time,[1000,2000,3000],"#domi");
$("#spi").text(toThousands(data.results.rum_speed_index)+'ms');
toColor(data.results.rum_speed_index,[1000,2000,3000],"#spi");
$("#pgb").text(toThousands(data.results.page_bytes));
$("#pgt").text(toThousands(data.results.page_load_time)+'ms');
toColor(data.results.page_load_time,[1000,2000,3000],"#pgt");
$("#hb").text(toThousands(data.results.html_bytes));
$("#fl").text(toThousands(data.results.fully_loaded_time)+'ms');
toColor(data.results.fully_loaded_time,[1000,2000,3000],"#fl");
$("#hl").text(toThousands(data.results.html_load_time)+'ms');
toColor(data.results.html_load_time,[1000,2000,3000],"#hl");
$("#yslow").text(toThousands(data.results.yslow_score));
$("#pgs").text(toThousands(data.results.pagespeed_score));
$("#bt").text(toThousands(data.results.backend_duration)+'ms');
toColor(data.results.backend_duration,[500,1000,1500],"#bt");
$("#cnt").text(toThousands(data.results.connect_duration)+'ms');
toColor(data.results.connect_duration,[500,1000,1500],"#cnt");
if (data.results.pagespeed_score >= 90) {
$("#pgsc").addClass('green');
} else if (data.results.pagespeed_score < 90 && data.results.pagespeed_score >= 60) {
$("#pgsc").addClass('yellow');
} else if (data.results.pagespeed_score < 60 && data.results.pagespeed_score >= 30) {
$("#pgsc").addClass('orange');
} else {
$("#pgsc").addClass('red');
}
if (data.results.yslow_score >= 90) {
$("#yslowc").addClass('green');
} else if (data.results.yslow_score < 90 && data.results.yslow_score >= 60) {
$("#yslowc").addClass('yellow');
} else if (data.results.yslow_score < 60 && data.results.yslow_score >= 30) {
$("#yslowc").addClass('orange');
} else {
$("#yslowc").addClass('red');
}
});
</script>
</body>
</html>