-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
executable file
·144 lines (115 loc) · 4.83 KB
/
index.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wrk Benchmark Table</title>
<meta name="description" content="HTML-based table with fixed headers, fixed footers, fixed left columns, row selection, sorting and more. Open source.">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link href="assets/Grid.css" rel="stylesheet" type="text/css">
<style type="text/css">
</style>
</head>
<body>
<h1 id="hdr">Wrk Benchmark Table</h1>
<h3 id="hdr_meta"></h3>
<div id="demoDiv">
<div id="demoGrid">
<table id="demoTable">
<colgroup><col id="demoTableCol1"></colgroup>
<thead id='head'>
</thead>
<tbody id='body'>
</tbody>
</table>
</div>
</div>
<script src="assets/zepto.min.js"></script>
<script type="text/javascript" src="assets/Grid.js"></script>
<script type="text/javascript">
$(function(){
var filter = ["host","port","threads","connections"]
var items = ["time","latency_avg","latency_stdev","latency_max","latency_precent","req_per_second_avg","req_per_second_stdev","req_per_second_max","req_per_second_precent","requests_count","requests_seconds","requests_read","requests_per_sec","transfer_per_sec"];
$.get('logs/wrk_result.json', function(json){
var gridColSortTypes = []
var head_data = []
var body_data = []
var one = {}
for(var k in json){
var item = {}
item.key = k;
item.values = json[k];
var tds = [];
for (var filter_k in filter) {
one[filter[filter_k]] = item.values[filter[filter_k]]
delete item.values[filter[filter_k]]
}
for (var item_k in item.values) {
if(typeof item.values[item_k] !== 'number'){
tds.push("<td class='txt'>" + item.values[item_k] + "</td>")
gridColSortTypes.push('number')
}else{
tds.push("<td>" + item.values[item_k] + "</td>")
gridColSortTypes.push('string')
}
}
var body_tr = "<tr><td>" + item.key + "</td>" + tds.join('') + "</tr>"
body_data.push(body_tr);
}
if(one){
console.log(one)
var head_meta = ""
for(var k in one){
head_meta += k + ': ' + one[k] + ' '
}
$('#hdr').html('Wrk Benchmark Table ')
$('#hdr_meta').html(head_meta)
}
var tds_head = [];
for(var i in items){
console.log((parseInt(i)+1))
tds_head.push("<td><span id='demoHdr" + (parseInt(i) + 1) + "'>" + items[i] + "</span></td>")
}
var head_tr = "<tr><td class='num'><span id='demoHdr0'>分类</span></td>" + tds_head.join('') + "</tr>"
// head_data.push(head_tr);
$('#head').html(head_tr)
$('#body').html(body_data.join(''))
var gridColAlign = [];
var onColumnSort = function(newIndexOrder, columnIndex, lastColumnIndex) {
var offset = (this.options.allowSelections && this.options.showSelectionColumn) ? 1 : 0,
doc = document;
if (columnIndex !== lastColumnIndex) {
if (lastColumnIndex > -1) {
doc.getElementById("demoHdr" + (lastColumnIndex - offset)).parentNode.style.backgroundColor = "";
}
doc.getElementById("demoHdr" + (columnIndex - offset)).parentNode.style.backgroundColor = "#f7f7f7";
}
};
var onResizeGrid = function(newWidth, newHeight) {
var demoDivStyle = document.getElementById("demoDiv").style;
demoDivStyle.width = newWidth + "px";
demoDivStyle.height = newHeight + "px";
};
for (var i=0, col; col=gridColSortTypes[i]; i++) {
gridColAlign[i] = (col === "number") ? "right" : "left";
}
var myGrid = new Grid("demoGrid", {
srcType : "dom",
srcData : "demoTable",
allowGridResize : true,
allowColumnResize : true,
allowClientSideSorting : true,
allowSelections : true,
allowMultipleSelections : true,
showSelectionColumn : true,
onColumnSort : onColumnSort,
onResizeGrid : onResizeGrid,
colAlign : gridColAlign,
colBGColors : ["#fafafa"],
colSortTypes : gridColSortTypes,
fixedCols : 1
});
});
})
</script>
</body>
</html>