//初期化 function init(){ document.images["img1"].onload = stop_timer; document.images["img1"].onerror = error; document.images["img1"].onabort = abort; st_flg = 0;//計測中フラグ(0:未計測;1:計測中) line_flg = 0;//回線オプション(0:通常;1:高速) //測定用画像リスト設定 ImageList = new Array();//(ImageList[line_flg] = "画像パス:画像サイズ") ImageList[0] = 'bench.jpg:129693'; ImageList[1] = 'bench2.jpg:262678'; } //計測開始 function start_timer(){ if (!st_flg){ st_Time = (new Date()).getTime(); st_flg = 1; document.form1.text1.value="";//フォームクリア document.form1.text2.value="";//フォームクリア document.form1.text3.value="";//フォームクリア document.images["img1"].src = ImageList[line_flg].split(':')[0]+"?"+ Math.random();//キャッシュ防止 } } //計測終了 function stop_timer(){ if (st_flg) { end_Time = (new Date()).getTime(); time = (end_Time - st_Time)/1000; var ImageSize = eval(ImageList[line_flg].split(':')[1]); document.form1.text1.value = format(time,3); document.form1.text2.value = format(ImageSize/1024/time,3); document.form1.text3.value = format(ImageSize/1024/time*8,3); st_flg = 0; } } //桁揃え function format(val,digit){//val:数値;digit:桁 for (i=0;i<digit;i++) { val *= 10.0; } val = Math.round(val); val += ""; if (digit) { val = val.substring(0,val.length-digit) + "." + val.substring(val.length-digit,val.length); } return(val); } //読込み失敗時処理(動作しない環境が多い...) function error(){ if (st_flg) { alert('計測失敗!!\nもう一度計測してみてください。'); st_flg = 0; } } //読込みキャンセル時処理 function abort(){ if (st_flg) { alert('計測キャンセル!!\nもう一度計測してみてください。'); st_flg = 0; } }