XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Measuring the Time a Process takes

Last post 8/30/2009 8:27 PM by Greg the Mad. 2 replies.
  • 8/30/2009 6:55 PM

    Measuring the Time a Process takes

    I've writen a little 2D Triangle-Triangle Intersection method, and now I'm curious and what to know how it performs.
    How can a measure the time the method needs to calculate?


    Greg
  • 8/30/2009 8:06 PM In reply to

    Re: Measuring the Time a Process takes

    Answer
    Reply Quote
    Generate an array with 100 random triangles in it (from the (-2..2,-2..2,-2..2) range, say).
    Write a loop that tests every triangle against every other triangle (including testing against itself).
    Wrap the whole loop in a System.Diagnostics.Stopwatch timing bracket (start/stop).
    The Stopwatch will tell you how long it took to test 10,000 triangle pairs (when they are all in cache).
    Make sure to profile the release mode version of the code, and, if you target Xbox, to run this on the actual Xbox.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
  • 8/30/2009 8:27 PM In reply to

    Re: Measuring the Time a Process takes

    Hey, great!

    10.000 triangles are quite a lot for the little prototyp I'm making, as at the moment there are only two of them, and there never will be more then 100 triangles. 
    (its like pong, but I also plan rotated bars, for more then 4 players, so I need triangles)

    But if the thing is right it tooks my PC around 0.01ms to check two triangles. ... It took me 3 hours researching, 1 hour coding and 1 hour tuning this method ... they calculate so fast :´(

    Anyway, I will make a bigger performance check once I know how many triangle I will have in the final game.


    Thanks,
    Greg
Page 1 of 1 (3 items) Previous Next