Commit c9d56792 authored by Olav Kvittem's avatar Olav Kvittem

bug for x-axes in plot - now covers time from start of measurement

parent 0b2fbe17
......@@ -28,7 +28,7 @@ var sizesk=[28, 252, 2500, 25000];
var grafno=0;
var tablewidth=0;
var upcolor='#000374';
var upcolor='#000374'; // from uninett's palett
var downcolor='#00612b';
//var series=[{ 'name':'Download', data:[], type: 'scatter' , color: downcolor },
// { 'name':'Upload', data:[], type: 'scatter' , color: upcolor }];
......@@ -66,7 +66,7 @@ function get_progress(e, pregress) { // to be called onprogress in ajax
pregress.mbps=mbps;
}
var span=now-pregress.start;
var span=now-pregress.begin;
curseries.addPoint([span/1000, mbps]);
pregress.nmbps= mbps;
......@@ -80,6 +80,7 @@ function get_progress(e, pregress) { // to be called onprogress in ajax
}
}
return true;
}
function progress_speed( pregress, speed){
......@@ -103,11 +104,12 @@ function progress_speed( pregress, speed){
}
function TestDownload(speedclass) {
start = new Date().getTime();
now = new Date().getTime();
var pregress={
dir: "down",
loaded: 0,
start: start,
start: now,
begin: now,
mbps: 0,
nmbps: 0,
n: 0,
......@@ -119,7 +121,7 @@ function TestDownload(speedclass) {
if ( speedclass == 0 ){ // make new series
seriesno++;
curseries=chart.addSeries( { 'name':'Download ' + seriesno, data:[], type: 'scatter' , color: downcolor });
}
}
pregress.total=sizesk[speedclass]*1000;
$("#dlspeed").html('<img src=busy.gif>');
......@@ -156,7 +158,7 @@ function TestDownload(speedclass) {
function download_success(msg){
binfile[speedclass] = msg;
end = new Date().getTime();
dldiff = (end - start) / 1000;
dldiff = (end - pregress.begin) / 1000;
bytes = msg.length;
dlspeed = (bytes * 8 / dldiff) / 1000/ 1000;
dlspeed = progress_speed( pregress, dlspeed );
......@@ -176,13 +178,14 @@ function TestDownload(speedclass) {
}
function TestUpload(speedclass) {
start = new Date().getTime();
function TestUpload(speedclass, start) {
var now = new Date().getTime();
$("#ulspeed").html('<img src=busy.gif>');
var pregress={
dir: "up",
loaded: 0,
start: start,
start: now, // start progess period
begin: now, // begin of test series
mbps: 0,
nmbps: 0,
series:[],
......@@ -204,10 +207,10 @@ function TestUpload(speedclass) {
dataType: 'text',
async: true,
xhr: function(){ // to get upload progress events
var xhr = $.ajaxSettings.xhr() ;
var xhr = $.ajaxSettings.xhr() ;
xhr.upload.onprogress = function(e) {progress_last= get_progress(e, pregress); return 0; };
// xhr.upload.addEventListener('progress', function(e) {progress_last= get_progress(e, pregress); }, false);
return xhr ;
// xhr.upload.addEventListener('progress', function(e) {progress_last= get_progress(e, pregress); }, false);
return xhr ;
},
// this this works for get
// xhrFields: {
......@@ -216,11 +219,11 @@ function TestUpload(speedclass) {
success: function(msg) {
end = new Date().getTime();
uldiff = ( end - start ) / 1000; // ms to sec
uldiff = ( end - pregress.begin ) / 1000; // ms to sec
if ( uldiff < min_test_length && (speedclass+1) < (binfile.length)){
console.log( 'class ' + speedclass + ' up time ' + uldiff);
TestUpload(speedclass+1);
} else {
console.log( 'class ' + speedclass + ' up time ' + uldiff);
bytes = binfile[speedclass].length;
ulspeed = (bytes * 8 / uldiff) / 1000 / 1000;
ulspeed=progress_speed( pregress, ulspeed );
......@@ -230,7 +233,7 @@ function TestUpload(speedclass) {
ulsum += ulspeed; uldiffsum += uldiff; ulno++;
ulavg=Math.round(ulsum/ulno*10)/10;
var speed=Math.max(ulavg, dlavg);
var speed=Math.max(ulavg, dlavg, ulspeed, dlspeed);
refv = speed.toPrecision(1);
// pixsz = $(window).width() / 2 / refv;
if ( tablewidth == 0 ){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment