The costs of methods

In one of Tom Millers books, he recommends knowing the cost of every method you use.
So, I'm wondering how to find out what methods cost to call/use.
Like changing the RenderState, or even just retrieving the the device reference.
Get/Set constructs must be quite cheap...
I've never used one, but is that what a profiler is for (Showing where resources go)





Answer this question

The costs of methods

  • Reznick

    Thanks all three, Very useful info there.

    I pulled this from Rico's site;

    Frank Hileman
    Poor software performance causes annoyance and wasted money. One way to get developers to appreciate the end-user annoyance is to simply put them into the same boat: give them a machine to work with with only a limited amount of RAM and CPU speed.

    Suddenly you find enormous efficiency gains in the software.

    Thats interesting because I've recently been thinking that I'm going to have to learn to write efficient code, because my current computer I work on is a P3 700mhz, 128 RAM machine.
    Heh.

    What prompted my first post was my thought,  I might as well learn to write efficient code from the start, instead of waiting until I'm an advanced programmer then unlearning bad habits.
    Looks like code performance is a whole field in itself.

    I try to keep in mind the advice: Make it work first, then worry about optomizing it


     



  • Mellis27

    I found this link just now, and posted it here in the unlikely event that someone would find it useful

    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dndotnet/html/fastmanagedcode.asp



  • naylouvar

    Since you're referring to Tom Miller's book, I'm assuming you're using C#. There's a great online book available on improving performance of .NET, but you may specifically want to read this chapter on profiling: http://msdn.microsoft.com/practices/Topics/perfscale/default.aspx pull=/library/en-us/dnpag/html/scalenethowto13.asp
    In addition, read EVERYTHING Rico Mariani has to say. He's a genius


  • CleffedUp

    Here's a fun little list I came across recently where all the render state changes were timed. There's nothing official about the list so they are probably driver/card/machine specific for the exact times but it gives you some kind of idea about what is cheap and what is more expensive

    http://www.circlesoft.org/pages.php pg=kbasepage&id=12



  • Toady

    I would say that your best bet is to look at Pix and how to use it effectively with Managed DirectX. It's a good start. Here are a few links to put you well on your way to becoming an PIX guru.
    Channel 9 Video demonstrating PIX
    C++ and PIX profiling
    For C#/VB.NET you can use the PixHelper.BeginEvent() and PixHelper.EndEvent() calls.

    I hope this helps.
    Take care.



  • The costs of methods