[Javascript] How quick is quick ?
liorean
liorean at gmail.com
Tue Nov 9 11:18:00 CST 2004
On Tue, 9 Nov 2004 16:36:11 -0000, Tim Makins <spindrift at oceanfree.net> wrote:
> A few comments recently about how this will take time, and how that will be really slow.
> It would be nice to know exactly - has anyone got a routine that monitors the time a javascript routine takes to operate ??
/* make sure everything that is needed for the test is done here,
before the first date. Examples are variable instantiation and static
parts such as caching values.*/
var
d=new Date;
/* dotest*/;
d-=new Date; // Stores the time difference directly after doing
the test. Note that this will be a negative value.
A typical example of this technique is the following benchmark:
var
i=5e5,
d=new Date;
do
/*whatever*/;
while(0<--i);
d-=new Date;
alert('Run time, 500 000 cycles: '+(-d));
--
David "liorean" Andersson
<uri:http://liorean.web-graphics.com/>
More information about the Javascript
mailing list