G
Guy
I would like to calculate the time it takes to load a picture in tenths of a
seconds. So I get the current time, load the image, and once loaded I get
the current time again.
I would like to know if it took 9.3 seconds or 9.7 seconds or whatever.
Can javascript get tenths of a second.
Thanks for all,
Guy
My current HTML document looks like this:
The calculation is based on the size of the file I was using.
<HTML>
<HEAD>
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Cache-Control" Content="max-age=0">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
<SCRIPT language=javascript>
var a;
var b;
var c;
var d;
var e;
var h;
var m;
var s;
var n;
n=0;
function gettime()
{
var t = new Date();
h = t.getHours();
m = t.getMinutes();
s = t.getSeconds();
}
function begin()
{
self.document.f1.i5.value='Testing...';
gettime();
a=s;
self.document.f1.i1.value=h + ":" + m + ":" + s;
self.document.f1.i2.value='';
if(n==0){n=1;self.document.pic.src='e1.gif';}
else{n=0;self.document.pic.src='e2.gif';}
}
function calc()
{
gettime();
b=s;
self.document.f1.i2.value=h + ":" + m + ":" + s;
if((b-a)<0){b=b+60;}
c=(b-a);
if(c<2)
{
d="";
e="";
self.document.f1.i5.value='You must delete your temporary Internet
Files';
}
else
{
d=Math.round(15994310/(c*1024))/10;
e=Math.round(15994310/c)/10;
self.document.f1.i5.value='Done!';
}
self.document.f1.i3.value=d;
self.document.f1.i4.value=e;
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<FORM name=f1>
<TABLE border=1><TR><TD align=center>
<BR>
<FONT SIZE=4>Trial Speed-Test site</FONT><BR><BR>
<TABLE cellspacing=0 cellpadding=2 border=0>
<TR><TD>Start time </TD><TD><INPUT name='i1' value=''>
</TD></TR>
<TR><TD>End Time </TD><TD><INPUT name='i2' value=''>
</TD></TR>
<TR><TD>Speed </TD><TD><INPUT name='i3' value=''> kilobytes per second
</TD></TR>
<TR><TD> </TD><TD><INPUT name='i4' value=''> Bytes per second
</TD></TR>
</TABLE>
<BR>
<IMG name='test' width=100 height=100 border=1 src='test.gif'
onclick='self.begin();'>
<BR><BR>
<INPUT name='i5' value='' size=50>
<IMG name='pic' width=0 height=0 border=0 src='' onload='self.calc();'>
</TD></TR></TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
seconds. So I get the current time, load the image, and once loaded I get
the current time again.
I would like to know if it took 9.3 seconds or 9.7 seconds or whatever.
Can javascript get tenths of a second.
Thanks for all,
Guy
My current HTML document looks like this:
The calculation is based on the size of the file I was using.
<HTML>
<HEAD>
<META Http-Equiv="Cache-Control" Content="no-cache">
<META Http-Equiv="Cache-Control" Content="max-age=0">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Expires" Content="0">
<SCRIPT language=javascript>
var a;
var b;
var c;
var d;
var e;
var h;
var m;
var s;
var n;
n=0;
function gettime()
{
var t = new Date();
h = t.getHours();
m = t.getMinutes();
s = t.getSeconds();
}
function begin()
{
self.document.f1.i5.value='Testing...';
gettime();
a=s;
self.document.f1.i1.value=h + ":" + m + ":" + s;
self.document.f1.i2.value='';
if(n==0){n=1;self.document.pic.src='e1.gif';}
else{n=0;self.document.pic.src='e2.gif';}
}
function calc()
{
gettime();
b=s;
self.document.f1.i2.value=h + ":" + m + ":" + s;
if((b-a)<0){b=b+60;}
c=(b-a);
if(c<2)
{
d="";
e="";
self.document.f1.i5.value='You must delete your temporary Internet
Files';
}
else
{
d=Math.round(15994310/(c*1024))/10;
e=Math.round(15994310/c)/10;
self.document.f1.i5.value='Done!';
}
self.document.f1.i3.value=d;
self.document.f1.i4.value=e;
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER>
<FORM name=f1>
<TABLE border=1><TR><TD align=center>
<BR>
<FONT SIZE=4>Trial Speed-Test site</FONT><BR><BR>
<TABLE cellspacing=0 cellpadding=2 border=0>
<TR><TD>Start time </TD><TD><INPUT name='i1' value=''>
</TD></TR>
<TR><TD>End Time </TD><TD><INPUT name='i2' value=''>
</TD></TR>
<TR><TD>Speed </TD><TD><INPUT name='i3' value=''> kilobytes per second
</TD></TR>
<TR><TD> </TD><TD><INPUT name='i4' value=''> Bytes per second
</TD></TR>
</TABLE>
<BR>
<IMG name='test' width=100 height=100 border=1 src='test.gif'
onclick='self.begin();'>
<BR><BR>
<INPUT name='i5' value='' size=50>
<IMG name='pic' width=0 height=0 border=0 src='' onload='self.calc();'>
</TD></TR></TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>