forked from skycube/jqspeedtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
latency.js
60 lines (60 loc) · 1.51 KB
/
latency.js
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
/******************************************************
* START CODE FOR DEMO 3
* Example which morris
******************************************************/
$("#Demo-3-StartButton").click(function(e){
$('#Demo-3-StartButton').hide();
$('#Demo-3-StopButton').show();
chartData = [];
Demo3 = new JQSpeedTest({
countDlSamples:0,
countUlSamples:0,
countReSamples:100,
testSleepTime: 500,
returnUnits: false,
testStateCallback: Demo3callBackFunctionState,
testFinishCallback: Demo3callbackFunctionFinish,
testReCallback: Demo3callbackFunctionRe,
});
});
/** Demo3 Stop Button **/
$('#Demo-3-StopButton').click(function(e){
Demo3.state('forcestop');
});
/** Demo3 Sample Call Back Function for State **/
function Demo3callBackFunctionState(value){
$('#Demo-3-State').text(value);
}
/** Demo3 Sample Call Back Function for Finshi **/
function Demo3callbackFunctionFinish(value){
$('#Demo-3-StartButton').show();
$('#Demo-3-StopButton').hide();
}
/** Chart Data init **/
var chartData = [];
chartData.push({
x: new Date().getTime(),
y: '0'
});
/** Demo3 Sample Call Back Function for Response Time **/
function Demo3callbackFunctionRe(val){
if(val>300) val = 300; // Little Hack
chartData.push({
x: new Date().getTime(),
y: val
});
Demo3graph.setData(chartData);
}
/** Demo3 Morris Chart **/
var Demo3graph = Morris.Line({
element: 'Demo-3-graph',
data: chartData,
xkey: 'x',
ykeys: ['y'],
labels: ['Response time'],
parseTime: true,
ymin: 'auto',
ymax: 'auto',
postUnits: ' ms',
hideHover: true
});