dashboard.js.fmkr
7.11 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
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
var showControllersOnly = ${showControllersOnly?c!"false"};
var seriesFilter = ${seriesFilter!"undefined"};
var filtersOnlySampleSeries = ${filtersOnlySampleSeries?c!"false"};
/*
* Add header in statistics table to group metrics by category
* format
*
*/
function summaryTableHeader(header) {
var newRow = header.insertRow(-1);
newRow.className = "tablesorter-no-sort";
var cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 1;
cell.innerHTML = "Requests";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 3;
cell.innerHTML = "Executions";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 7;
cell.innerHTML = "Response Times (ms)";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 2;
cell.innerHTML = "Network (KB/sec)";
newRow.appendChild(cell);
}
/*
* Populates the table identified by id parameter with the specified data and
* format
*
*/
function createTable(table, info, formatter, defaultSorts, seriesIndex, headerCreator) {
var tableRef = table[0];
// Create header and populate it with data.titles array
var header = tableRef.createTHead();
// Call callback is available
if(headerCreator) {
headerCreator(header);
}
var newRow = header.insertRow(-1);
for (var index = 0; index < info.titles.length; index++) {
var cell = document.createElement('th');
cell.innerHTML = info.titles[index];
newRow.appendChild(cell);
}
var tBody;
// Create overall body if defined
if(info.overall){
tBody = document.createElement('tbody');
tBody.className = "tablesorter-no-sort";
tableRef.appendChild(tBody);
var newRow = tBody.insertRow(-1);
var data = info.overall.data;
for(var index=0;index < data.length; index++){
var cell = newRow.insertCell(-1);
cell.innerHTML = formatter ? formatter(index, data[index]): data[index];
}
}
// Create regular body
tBody = document.createElement('tbody');
tableRef.appendChild(tBody);
var regexp;
if(seriesFilter) {
regexp = new RegExp(seriesFilter, 'i');
}
// Populate body with data.items array
for(var index=0; index < info.items.length; index++){
var item = info.items[index];
if((!regexp || filtersOnlySampleSeries && !info.supportsControllersDiscrimination || regexp.test(item.data[seriesIndex]))
&&
(!showControllersOnly || !info.supportsControllersDiscrimination || item.isController)){
if(item.data.length > 0) {
var newRow = tBody.insertRow(-1);
for(var col=0; col < item.data.length; col++){
var cell = newRow.insertCell(-1);
cell.innerHTML = formatter ? formatter(col, item.data[col]) : item.data[col];
}
}
}
}
// Add support of columns sort
table.tablesorter({sortList : defaultSorts});
}
$(document).ready(function() {
// Customize table sorter default options
$.extend( $.tablesorter.defaults, {
theme: 'blue',
cssInfoBlock: "tablesorter-no-sort",
widthFixed: true,
widgets: ['zebra']
});
var data = ${requestsSummary!"{}"};
var dataset = [
{
"label" : "KO",
"data" : data.KoPercent,
"color" : "#FF6347"
},
{
"label" : "OK",
"data" : data.OkPercent,
"color" : "#9ACD32"
}];
$.plot($("#flot-requests-summary"), dataset, {
series : {
pie : {
show : true,
radius : 1,
label : {
show : true,
radius : 3 / 4,
formatter : function(label, series) {
return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'
+ label
+ '<br/>'
+ Math.round10(series.percent, -2)
+ '%</div>';
},
background : {
opacity : 0.5,
color : '#000'
}
}
}
},
legend : {
show : true
}
});
// Creates APDEX table
createTable($("#apdexTable"), ${apdexSummary!"{}"}, function(index, item){
switch(index){
case 0:
item = item.toFixed(3);
break;
case 1:
case 2:
item = formatDuration(item);
break;
}
return item;
}, [[0, 0]], 3);
// Create statistics table
createTable($("#statisticsTable"), ${statisticsSummary!"{}"}, function(index, item){
switch(index){
// Errors pct
case 3:
item = item.toFixed(2) + '%';
break;
// Mean
case 4:
// Mean
case 7:
// Percentile 1
case 8:
// Percentile 2
case 9:
// Percentile 3
case 10:
// Throughput
case 11:
// Kbytes/s
case 12:
// Sent Kbytes/s
item = item.toFixed(2);
break;
}
return item;
}, [[0, 0]], 0, summaryTableHeader);
// Create error table
createTable($("#errorsTable"), ${errorsSummary!"{}"}, function(index, item){
switch(index){
case 2:
case 3:
item = item.toFixed(2) + '%';
break;
}
return item;
}, [[1, 1]]);
// Create top5 errors by sampler
createTable($("#top5ErrorsBySamplerTable"), ${top5ErrorsBySampler!"{}"}, function(index, item){
return item;
}, [[0, 0]], 0);
});