|
|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
[mx04] calculating script execution time - path finding
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! |
|
|
|
|
|
#2 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
|
__________________
![]() AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#3 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
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? |
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
|
getMilliseconds() then?
gparis
__________________
![]() AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#5 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
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! Last edited by chriso20; 02-18-2007 at 10:36 PM. |
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
|
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
__________________
![]() AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#7 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
lol oh yea... amazing how well you can concentrate at 3am
![]() thanks again |
|
|
|
|
|
#8 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
|
another thought: setInterval() may still help... as an indicator only, in case you go over 2 seconds.
good night ![]() gparis
__________________
![]() AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
|
|
#9 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
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? |
|
|
|
|
|
#10 |
|
Pixel Artéést
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
|
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. |
|
|
|
|
|
#11 |
|
Super Moderator
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
|
Well. Guess that method is not efficient then. Try the basic getTimer() , see if it yields more consistent results.
gparis
__________________
![]() AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4) |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|