Hey,
can someone tell me how i can work out how long a path finding script took to calculate?
like they do in this example;
http://www.luar.com.hk/demo/pathfinding.htm
(middle value at the bottom is time taken in ms)
thanks in advance!
Printable View
Hey,
can someone tell me how i can work out how long a path finding script took to calculate?
like they do in this example;
http://www.luar.com.hk/demo/pathfinding.htm
(middle value at the bottom is time taken in ms)
thanks in advance!
setInterval() can give you a precise millisecond count.
gparis
setInterval isn't accurate, there have been tests that show it can be like 1/3 second off at times and when we're dealing with milliseconds, that's a long time!
I could get the global time code thing for when i ran the script and again when it finished i suppose?
getMilliseconds() then?
gparis
hmmm... yeah i suppose this is the only way to do it.
If i'm only using the getMilliseconds() though then if the path finding takes longer than a second (verrrry unlikely) then it'd show a false reading (incl. negative reading)
Thanks gparis (p.s. like your site ;))
EDIT: also and this is a big deal, if the ms is on like 999 and then it takes 12 ms to run it'l show 999 at the start and 11 at the end! that's completely wrong! argh!
you get them at start(pointA), then at the end(pointB) the length would be pointB - pointA. for that issue, add an if(pointB<pointA) pointB+=1000
thanks for the ps ;)
gparis
lol oh yea... amazing how well you can concentrate at 3am :)
thanks again
another thought: setInterval() may still help... as an indicator only, in case you go over 2 seconds.
good night ;)
gparis
for some reasons i'm not getting consistent results.
when i do a simple path find from one corner of a 10*10 grid to another, it comes up with either 0, 15 or 16 ms.
i'm guessing 15/16 is correct, however why does it come up with 0?
I THINK what it's doing is on one frame / clock cycle (do they even apply to flash?) i click the 'find path' button and it sets the start milliseconds and then in the same cycle it finds the path and sets the end milliseconds. thus giving a 0 difference as it only did one cycle, and only set the time once. on the occasions it gives 15/16 it must be doing it on 2 sepperate cycles, first setting the start time, second setting the end time and completing the path find.
what do you think?
also :
I've run it at 120fps and it's still 50/50 wether it shows 15/16 or 0 so that kind of rules out what i said before.
Well. Guess that method is not efficient then. Try the basic getTimer() , see if it yields more consistent results.
gparis