XNA Creators Club Online
Page 2 of 2 (33 items) < Previous 1 2
Sort Posts: Previous Next

C# Array[] speed vs List<> speed

Last post 3/2/2010 11:12 AM by Bob Taco Ind. 32 replies.
  • 6/19/2009 5:20 PM In reply to

    Re: C# Array[] speed vs List<> speed

    http://msdn.microsoft.com/en-us/library/system.math.round.aspx

    Adding .5 works properly for +ve values only (most of the time for drawing sprites unless you have some transforms involved)

    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 6/19/2009 5:22 PM In reply to

    Re: C# Array[] speed vs List<> speed

    Brilliant !!

    Thanks !
  • 6/19/2009 5:26 PM In reply to

    Re: C# Array[] speed vs List<> speed

    Yes, is only for positive values in this case.

    Thanks
  • 2/27/2010 6:57 PM In reply to

    Re: C# Array[] speed vs List<> speed

    Nick Gravelyn:
    ... the size of T might be affecting performance somehow.


    The size of the objects contained by the collection can definitely determine the speed of performance. Using millions of reference type objects, for example, could be much slower than using the same number of value types.
    "It's pure sawesome!"
    http://hr.michaelgh.com/
  • 3/1/2010 11:53 AM In reply to

    Re: C# Array[] speed vs List<> speed

    Use List for luxury and array[] for raw speed

    if you use Lists on tight loops your perfomance will go down the drain
    there are some flaws in perfomance with .net when it comes down to things like that especially on the xbox
    i used Lists for everything in my game and i paid the price for it...
    the thing that kills perfomance is when you have to read an item on the list

    the rendering loop in my game uses Lists to traverse all objects and flag them as renderable or not
    profiler shows around 30%+ of time is spend on reading items from Lists

    and its like that in many places in my code

    In Review: Masters of Belial

    Visit Brain Seal on Facebook
  • 3/2/2010 2:39 AM In reply to

    Re: C# Array[] speed vs List<> speed

    On the subject of arrays, does anyone know how good the .NET compact VM is at array bounds check elimination? I'm used to developing for Sun's Java VM, which is very good at eliminating bounds checks - certainly if you do a linear scan through an array, it will check bounds at most once. However I'm not sure if the .NET VM on the Xbox is capable of array bounds check elimination or under what conditions. Probably not a major issue as most of the time you would be limited by cache / memory bandwidth anyway, but still, it would be nice to know.
  • 3/2/2010 8:59 AM In reply to

    Re: C# Array[] speed vs List<> speed

    mghoffmann:
    Nick Gravelyn:
    ... the size of T might be affecting performance somehow.


    The size of the objects contained by the collection can definitely determine the speed of performance. Using millions of reference type objects, for example, could be much slower than using the same number of value types.


    For an array or List? Using reference types in a list would be faster than using something like a Matrix, as every time you access the object in the list, since it's a ValueType and returned through a property, it's passing by value resulting in more overhead. An array doesn't have the same limitation.
  • 3/2/2010 11:12 AM In reply to

    Re: C# Array[] speed vs List<> speed

    Nick Gravelyn:

    public static int MyRound(float input) 

       return (int)(input + .5f); 



    I like this a lot.  I updated it as such, though.  Thoughts?

        public static int MyRound(float input)  
        {  
            return (int)(input > 0 ? (input + .5f) : (input - .5f));  
        }  
     
Page 2 of 2 (33 items) < Previous 1 2 Previous Next