llanitedave
08-05-2004, 05:59 PM
It might just be me, but I can't figure it out. My getTime() code is inconsistent and inaccurate.
function mainLoop(lots, of, parameters)
{
var getStartTime = new Date().getTime();
while (notStoppedYet)
{
doLots(of, looping, complex, stuff);
checkSome(data);
....
}
// get the total time elapsed
var getStopTime = new Date().getTime();
var timePassed = getStopTime - getStartTime;
alert(timePassed);
}
I have checked this function numerous times with my handy-dandy wristwatch. It averages about 26 seconds to complete.
Yet my timePassed alert returns values like:
4,...6,...5,...
I thought (1) that the time would be in milliseconds. Obviously, it's not. Even so, (2)I can't figure out why it should be so inaccurate.
Can anybody imagine what I might be overlooking?
Thanks!
function mainLoop(lots, of, parameters)
{
var getStartTime = new Date().getTime();
while (notStoppedYet)
{
doLots(of, looping, complex, stuff);
checkSome(data);
....
}
// get the total time elapsed
var getStopTime = new Date().getTime();
var timePassed = getStopTime - getStartTime;
alert(timePassed);
}
I have checked this function numerous times with my handy-dandy wristwatch. It averages about 26 seconds to complete.
Yet my timePassed alert returns values like:
4,...6,...5,...
I thought (1) that the time would be in milliseconds. Obviously, it's not. Even so, (2)I can't figure out why it should be so inaccurate.
Can anybody imagine what I might be overlooking?
Thanks!