Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
M
mp-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maalepaaler
mp-web
Commits
b23f11bb
Commit
b23f11bb
authored
Feb 18, 2015
by
Olav Kvittem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added paralell tests and selectable length
parent
444ef4c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
31 deletions
+58
-31
yt/jsbandwidth-body.html
yt/jsbandwidth-body.html
+6
-4
yt/jsbandwidth.js
yt/jsbandwidth.js
+52
-27
No files found.
yt/jsbandwidth-body.html
View file @
b23f11bb
<style>
th
{
background-color
:
#edebe0
}
td
{
text-align
:
right
;
}
.bar
{
text-align
:
left
;
}
</style>
<h3>
Yt - Simple web throughput test
</h3>
<div
class=
"col-lg-12 gutter uninett-padded uninett-color-lightBlue"
>
...
...
@@ -69,16 +71,16 @@ at about <td><form name="speedtest" id="speedform">
-->
<tr><th
title=
"From remote to you"
>
Download
<td
id=
dlspeed
><td
id=
dlsingle
><td
id=
dldiff
><td
id=
dlbytes
>
<td><img
id=
"dlbar"
src=
"down.png"
style=
"width: 1px; height: 10px;"
>
<td
class=
bar
><img
id=
"dlbar"
src=
"down.png"
style=
"width: 1px; height: 10px;"
>
<tr><th
title=
"Average of all runs"
>
-
average
<td
id=
dlspeedavg
><td
id=
dlsingleavg
><td
id=
dldiffavg
><td
id=
dlbytesavg
>
<td><img
id=
"dlbaravg"
src=
"down.png"
style=
"width: 1px; height: 10px;"
>
<td
class=
bar
><img
id=
"dlbaravg"
src=
"down.png"
style=
"width: 1px; height: 10px;"
>
<tr><th
title=
"From you to remote"
>
Upload
<td
id=
ulspeed
><td
id=
ulsingle
><td
id=
uldiff
><td
id=
ulbytes
>
<td><img
id=
"ulbar"
src=
"up.png"
style=
"width: 1px; height: 10px;"
>
<td
class=
bar
><img
id=
"ulbar"
src=
"up.png"
style=
"width: 1px; height: 10px;"
>
<tr><th
title=
"Average of all runs"
>
-
average
<td
id=
ulspeedavg
><td
id=
ulsingleavg
><td
id=
uldiffavg
><td
id=
ulbytesavg
>
<td><img
id=
"ulbaravg"
src=
"up.png"
style=
"width: 1px; height: 10px;"
>
<td
class=
bar
><img
id=
"ulbaravg"
src=
"up.png"
style=
"width: 1px; height: 10px;"
>
</table>
</div>
...
...
yt/jsbandwidth.js
View file @
b23f11bb
...
...
@@ -5,9 +5,9 @@ var opera=navigator.userAgent.match(/^Opera/) != null;
var
firefox
=
navigator
.
userAgent
.
match
(
/Firefox/
)
!=
null
;
var
min_test_length
=
0.5
;
// minimum testing period seconds
var
max_test_length
=
5
;
// maximum testing period seconds
var
max_test_length
=
1
;
// maximum testing period seconds
var
max_test_size
=
500000000
;
// in byte
var
min_progress_interval
=
2
0
;
// min interval in ms to be used for estimates (50ms onprogress)
var
min_progress_interval
=
50
0
;
// min interval in ms to be used for estimates (50ms onprogress)
var
test_period
=
6000
;
// interrup test after ms
//var speeds=["100k", "1M", "10M", "100M", "1000M", "5000M"];
var
sizesk
=
[
25
,
250
,
2500
,
25000
,
250000
,
500000
];
...
...
@@ -36,13 +36,16 @@ var dlprobjs=[], ulprobjs=[]; // list of test progress objects
var
dlseries
=
[],
ulseries
=
[];
var
dlseriesno
=
[],
ulseriesno
=
[];
var
runno
=
0
;
var
runs
=
[];
var
noparallels
=
[];
// parallels per run
var
perf_stat
=
{
down
:{},
up
:{}};
var
temp_speed
=
[],
temp_span
=
[],
temp_series
=
[];
// agregate progress_speed per direction
var
grafno
=
0
;
var
tablewidth
=
0
;
var
upcolor
=
'
#000374
'
;
// from uninett's palett
var
downcolor
=
'
#00612b
'
;
var
colors
=
{
'
up
'
:
upcolor
,
'
down
'
:
downcolor
};
//var series=[{ 'name':'Download', data:[], type: 'scatter' , color: downcolor },
// { 'name':'Upload', data:[], type: 'scatter' , color: upcolor }];
var
chart
;
...
...
@@ -73,6 +76,8 @@ function test_performance(dir){
var
parallels
=
parseInt
(
$
(
'
#parallels
'
).
val
());
noparallels
[
runno
]
=
parallels
;
var
duration
=
parseInt
(
$
(
'
#duration
'
).
val
());
test_period
=
duration
*
1000
*
1.2
;
// timeout if too long
// var uploadseq = $('#uploadseq').val();
...
...
@@ -165,7 +170,23 @@ function get_progress(e, probj) { // to be called onprogress in ajax
}
var
span
=
now
-
probj
.
begin
;
probj
.
series
.
addPoint
([
span
/
1000
,
mbps
]);
// probj.series.addPoint([span/1000, mbps]);
if
(
!
temp_speed
[
probj
.
dir
]
){
temp_speed
[
probj
.
dir
]
=
new
stats
();
temp_span
[
probj
.
dir
]
=
new
stats
();
var
str
=
probj
.
dir
;
str
=
str
.
substring
(
0
,
1
).
toUpperCase
()
+
str
.
substring
(
1
,
str
.
length
);
// capitalize
temp_series
[
probj
.
dir
]
=
chart
.
addSeries
(
{
'
name
'
:
str
+
'
load
'
+
'
..
'
,
data
:[],
type
:
'
scatter
'
,
color
:
colors
[
probj
.
dir
]
});
}
temp_speed
[
probj
.
dir
].
add
(
mbps
);
temp_span
[
probj
.
dir
].
add
(
span
);
if
(
temp_speed
[
probj
.
dir
].
n
%
noparallels
[
probj
.
runno
]
==
0
){
temp_series
[
probj
.
dir
].
addPoint
([
temp_span
[
probj
.
dir
].
average
()
/
1000
,
temp_speed
[
probj
.
dir
].
sum
]);
temp_speed
[
probj
.
dir
]
=
new
stats
();
temp_span
[
probj
.
dir
]
=
new
stats
();
}
probj
.
nmbps
=
mbps
;
probj
.
n
++
;
...
...
@@ -174,7 +195,7 @@ function get_progress(e, probj) { // to be called onprogress in ajax
probj
.
interval
=
dt
;
}
else
{
console
.
log
(
'
progress err
'
+
dt
+
'
ms
'
+
(
loaded
/
e
.
total
*
100
).
toFixed
(
2
)
+
'
%
'
+
'
-
'
+
loaded
+
'
-
'
+
e
.
total
+
'
now
'
+
e
.
timeStamp
+
'
then
'
+
probj
.
start
);
//
console.log( 'progress err ' + dt + 'ms ' + (loaded / e.total * 100).toFixed(2) + '%' + ' - ' + loaded + ' - ' + e.total + ' now ' + e.timeStamp + ' then ' + probj.start);
}
}
...
...
@@ -231,8 +252,8 @@ function TestDownload(runno, id, speedclass, testbytes, duration) {
dlprobjs
.
push
(
probj
);
if
(
speedclass
==
0
){
// make new series
if
(
dlseriesno
[
id
])
{
dlseriesno
[
id
]
++
}
else
{
dlseriesno
[
id
]
=
1
;}
dlseries
[
id
]
=
chart
.
addSeries
(
{
'
name
'
:
'
Download
'
+
runno
+
'
.
'
+
id
,
data
:[],
type
:
'
scatter
'
,
color
:
downcolor
});
//
if (dlseriesno[id]) {dlseriesno[id]++} else {dlseriesno[id]=1;}
//
dlseries[id]=chart.addSeries( { 'name':'Download ' + runno + '.' + id, data:[], type: 'scatter' , color: downcolor });
}
probj
.
series
=
dlseries
[
id
];
if
(
testbytes
>
0
){
...
...
@@ -264,6 +285,7 @@ function TestDownload(runno, id, speedclass, testbytes, duration) {
timeout
:
test_period
,
error
:
function
(
xhr
,
textStatus
,
errorThrown
){
if
(
textStatus
===
'
timeout
'
){
probj
.
done
=
true
;
download_success
(
''
,
probj
);
download_complete
(
xhr
,
probj
);
console
.
log
(
'
timeout
'
);
...
...
@@ -295,15 +317,16 @@ function TestDownload(runno, id, speedclass, testbytes, duration) {
function
download_complete
(
xhr
,
probj
){
if
(
(
speedclass
+
1
)
>=
(
sizesk
.
length
)
){
if
(
(
speedclass
+
1
)
>=
(
sizesk
.
length
)
||
probj
.
done
){
console
.
log
(
'
Too large file needed
'
+
'
class
'
+
speedclass
+
'
down time
'
+
probj
.
dldiff
+
'
bytes
'
+
probj
.
total
);
sumdown
(
probj
);
// check_for_upload();
}
else
{
if
(
probj
.
dldiff
>
min_test_length
){
if
(
probj
.
dldiff
<
max_test_length
*
0.80
){
// project size to give max_length
if
(
probj
.
dldiff
<
duration
*
0.80
){
// project size to give max_length
var
test_size
=
Math
.
min
(
max_test_size
,
probj
.
bytes
/
probj
.
dldiff
*
duration
);
probj
.
done
=
true
;
TestDownload
(
runno
,
id
,
speedclass
+
1
,
test_size
,
duration
);
console
.
log
(
'
last shot
'
+
probj
.
dir
+
'
'
+
'
class
'
+
(
speedclass
+
1
)
+
'
sizek
'
+
test_size
.
toFixed
(
1
)
);
}
else
{
...
...
@@ -336,9 +359,9 @@ function TestUpload(runno, id, speedclass, testbytes, duration) {
ulprobjs
.
push
(
probj
);
if
(
speedclass
==
0
){
if
(
ulseriesno
[
id
])
{
ulseriesno
[
id
]
++
}
else
{
ulseriesno
[
id
]
=
1
;
}
ulseries
[
id
]
=
chart
.
addSeries
(
{
'
name
'
:
'
Upload
'
+
runno
+
'
.
'
+
id
,
data
:[],
type
:
'
scatter
'
,
color
:
upcolor
}
);
//
if (ulseriesno[id]) { ulseriesno[id]++ } else { ulseriesno[id]=1; }
//
ulseries[id]=chart.addSeries( { 'name':'Upload '+ runno + '.' + id , data:[],
//
type: 'scatter' , color: upcolor } );
}
probj
.
series
=
ulseries
[
id
];
...
...
@@ -412,7 +435,7 @@ function TestUpload(runno, id, speedclass, testbytes, duration) {
}
else
{
if
(
probj
.
uldiff
>
min_test_length
){
if
(
probj
.
uldiff
<
max_test_length
*
0.80
){
// project size to give max_length
if
(
probj
.
uldiff
<
duration
*
0.80
){
// project size to give max_length
var
test_size
=
Math
.
min
(
max_test_size
,
probj
.
bytes
/
probj
.
uldiff
*
duration
);
TestUpload
(
runno
,
id
,
speedclass
+
1
,
test_size
,
duration
);
...
...
@@ -454,15 +477,15 @@ function sumdown(probj){
// $('#dlspeed').html(Math.(dlspeed*10)/10);
var
runspeed
=
ps
.
speed
[
run
].
sum
;
$
(
'
#dlspeed
'
).
html
(
runspeed
.
toPrecision
(
2
));
$
(
'
#dlsingle
'
).
html
(
dlavg
.
toPrecision
(
2
));
$
(
'
#dldiff
'
).
html
(
ps
.
time
[
run
].
average
().
toPrecision
(
2
)
+
'
s
'
);
$
(
'
#dlbytes
'
).
html
(
(
(
ps
.
bytes
[
run
].
sum
)
/
1000000
).
toPrecision
(
2
)
);
$
(
'
#dlspeed
'
).
html
(
runspeed
.
toPrecision
(
3
));
$
(
'
#dlsingle
'
).
html
(
dlavg
.
toPrecision
(
3
));
$
(
'
#dldiff
'
).
html
(
ps
.
time
[
run
].
average
().
toPrecision
(
3
)
+
'
s
'
);
$
(
'
#dlbytes
'
).
html
(
(
(
ps
.
bytes
[
run
].
sum
)
/
1000000
).
toPrecision
(
3
)
);
$
(
'
#dlspeedavg
'
).
html
(
average_sum
(
ps
.
speed
).
toPrecision
(
2
));
$
(
'
#dlsingleavg
'
).
html
(
average_all
(
ps
.
speed
).
toPrecision
(
2
));
$
(
'
#dldiffavg
'
).
html
(
average_all
(
ps
.
time
).
toPrecision
(
2
)
+
'
s
'
);
$
(
'
#dlbytesavg
'
).
html
(
(
average_sum
(
ps
.
bytes
)
/
1000000
).
toPrecision
(
2
)
);
$
(
'
#dlspeedavg
'
).
html
(
average_sum
(
ps
.
speed
).
toPrecision
(
3
));
$
(
'
#dlsingleavg
'
).
html
(
average_all
(
ps
.
speed
).
toPrecision
(
3
));
$
(
'
#dldiffavg
'
).
html
(
average_all
(
ps
.
time
).
toPrecision
(
3
)
+
'
s
'
);
$
(
'
#dlbytesavg
'
).
html
(
(
average_sum
(
ps
.
bytes
)
/
1000000
).
toPrecision
(
3
)
);
if
(
tablewidth
==
0
){
tablewidth
=
$
(
"
#result
"
).
width
();
...
...
@@ -483,15 +506,16 @@ function sumdown(probj){
console
.
log
(
'
histo
'
+
Math
.
round
(
runspeed
*
pixsz
)
+
'
px
'
+
Math
.
round
(
average_sum
(
ps
.
speed
)
*
pixsz
)
+
'
px
'
+
thruwidth
);
// length of line will indicate max test period
var
dldata
=
[
[
0
,
dlavg
],
[
Math
.
max
.
apply
(
Math
,
dldiffs
),
dlavg
]
];
// var dldata= [ [0, dlavg], [Math.max.apply(Math, dldiffs), dlavg] ];
var
dldata
=
[
[
0
,
ps
.
speed
[
run
].
sum
],
[
Math
.
max
.
apply
(
Math
,
dldiffs
),
ps
.
speed
[
run
].
sum
]
];
if
(
dlseriesavg
){
dlseriesavg
.
update
({
data
:
dldata
});
}
else
{
dlseriesavg
=
chart
.
addSeries
({
name
:
'
Download avg
'
,
data
:
dldata
,
color
:
downcolor
},
true
);
}
chart
.
yAxis
[
0
].
update
(
{
min
:
0
,
max
:
2
*
Math
.
max
(
average_all
(
perf_stat
.
down
.
speed
),
average_all
(
perf_stat
.
up
.
speed
)
)
});
//
chart.yAxis[0].update( { min: 0, max: 2*
//
Math.max(average_all(perf_stat.down.speed), average_all(perf_stat.up.speed) ) });
// Math.max(dlavg, ulavg) } );
ResultsUpload
(
"
download
"
,
runspeed
,
rtt
,
probj
.
start
);
...
...
@@ -550,15 +574,16 @@ function sumup(probj){
console
.
log
(
"
tablewidth
"
+
tablewidth
+
"
what
"
+
$
(
"
#what
"
).
width
()
+
"
#ulspeed
"
+
$
(
'
#ulspeed
'
).
width
()
+
"
uldiff
"
+
$
(
'
#uldiff
'
).
width
()
+
"
thruwidth
"
+
thruwidth
+
"
refv
"
+
refv
);
var
uldata
=
[
[
0
,
ulavg
],
[
Math
.
max
.
apply
(
Math
,
uldiffs
),
ulavg
]
];
// var uldata= [ [0, ulavg], [Math.max.apply(Math, uldiffs), ulavg] ];
var
uldata
=
[
[
0
,
ps
.
speed
[
run
].
sum
],
[
Math
.
max
.
apply
(
Math
,
uldiffs
),
ps
.
speed
[
run
].
sum
]
];
if
(
ulseriesavg
){
ulseriesavg
.
update
({
data
:
uldata
});
}
else
{
ulseriesavg
=
chart
.
addSeries
({
name
:
'
Upload avg
'
,
data
:
uldata
,
color
:
upcolor
},
true
);
}
chart
.
yAxis
[
0
].
update
(
{
min
:
0
,
max
:
2
*
Math
.
max
(
average_all
(
perf_stat
.
down
.
speed
),
average_all
(
perf_stat
.
up
.
speed
)
)
});
//
chart.yAxis[0].update( { min: 0, max: 2*
//
Math.max(average_all(perf_stat.down.speed), average_all(perf_stat.up.speed) ) });
ResultsUpload
(
"
upload
"
,
runspeed
,
rtt
,
probj
.
start
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment