To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Reply
 
Thread Tools Search this Thread Display Modes
Old 02-18-2007, 10:18 PM   #1
chriso20
Pixel Artéést
 
chriso20's Avatar
 
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!
chriso20 is offline   Reply With Quote
Old 02-18-2007, 10:25 PM   #2
gparis
Super Moderator
 
Join Date: Aug 2000
Location: Montréal
Posts: 13,430
setInterval() can give you a precise millisecond count.

gparis
__________________


AS 2.0 Forum Guidelines || Use P H P tags for code samples || Flash LiveDocs || AS 2.0 Language reference (CS4)
gparis is offline   Reply With Quote
Old 02-18-2007, 10:26 PM   #3
chriso20
Pixel Artéést
 
chriso20's Avatar
 
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?
chriso20 is offline   Reply With Quote
Old 02-18-2007, 10:29 PM   #4
gparis
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)
gparis is offline   Reply With Quote
Old 02-18-2007, 10:32 PM   #5
chriso20
Pixel Artéést
 
chriso20's Avatar
 
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.
chriso20 is offline   Reply With Quote
Old 02-18-2007, 11:04 PM   #6
gparis
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)
gparis is offline   Reply With Quote
Old 02-18-2007, 11:06 PM   #7
chriso20
Pixel Artéést
 
chriso20's Avatar
 
Join Date: Apr 2003
Location: Notts, UK
Posts: 325
lol oh yea... amazing how well you can concentrate at 3am

thanks again
chriso20 is offline   Reply With Quote
Old 02-18-2007, 11:21 PM   #8
gparis
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)
gparis is offline   Reply With Quote
Old 02-18-2007, 11:57 PM   #9
chriso20
Pixel Artéést
 
chriso20's Avatar
 
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?
chriso20 is offline   Reply With Quote
Old 02-19-2007, 01:27 AM   #10
chriso20
Pixel Artéést
 
chriso20's Avatar
 
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.
chriso20 is offline   Reply With Quote
Old 02-19-2007, 09:33 AM   #11
gparis
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)
gparis is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash ActionScript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:11 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.