A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [mx04] calculating script execution time - path finding

  1. #1
    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!

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    setInterval() can give you a precise millisecond count.

    gparis

  3. #3
    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?

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    getMilliseconds() then?

    gparis

  5. #5
    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.

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  7. #7
    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

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    another thought: setInterval() may still help... as an indicator only, in case you go over 2 seconds.
    good night

    gparis

  9. #9
    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?

  10. #10
    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.

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Well. Guess that method is not efficient then. Try the basic getTimer() , see if it yields more consistent results.

    gparis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center