Re: 3D Points (structs vs classes)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: cody (dont.spam.me.deutronium_at_gmx.de)
Date: 03/01/04


Date: Mon, 1 Mar 2004 21:06:34 +0100


"Fuzzy" <trnospam@earthlink.net> schrieb im Newsbeitrag
news:9527b23b.0403011157.596130fb@posting.google.com...
> "Eric Gunnerson [MS]" <ericgu@online.microsoft.com> wrote in message
news:<u1dQnzM$DHA.2476@TK2MSFTNGP12.phx.gbl>...
> > To echo what Frank said, the 16 byte part is a guideline.
> >
> > The tradeoff is between the time taken in your type be a reference type
(ie
> > allocation and GC overhead and overall memory pressure) vs the time it
takes
> > to copy the struct as parameters and return types, and any boxing
overhead.
> >
>
> So what's your opinion of passing larger structs around as ref
> parameters and eliminating the copy?

using ref eliminates the copy but through the extra indirection access to
the struct can get slower, I think.
but for larger structs (>16 bytes or more) it may save time, but this highly
depends on the specific application.
the most important thing when dealing with structs is that you must be
always awre of boxing, because boxing can be the biggest performance hit.

-- 
cody
[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk


Relevant Pages

  • Re: Why cant I inherit from DateTime?
    ... boxing, structs are faster and smaller which is why all the primatives are ... implicit conversion operators to simplify code e.g. IntegerType, StringType, ... Am I better using structs or classes? ... Joanna Carter ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: heap or stack?
    ... > Is there some middle ground - perhaps an array of structs containing ... > class make it an object and force it onto the heap. ... You don't need unsafe code to create structs, and you don't get boxing ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: 3D Points (structs vs classes)
    ... >> So what's your opinion of passing larger structs around as ref ... > using ref eliminates the copy but through the extra indirection access to ... > but for larger structs it may save time, ... > always awre of boxing, because boxing can be the biggest performance hit. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: 3D Points (structs vs classes)
    ... >> So what's your opinion of passing larger structs around as ref ... > using ref eliminates the copy but through the extra indirection access to ... > but for larger structs it may save time, ... > always awre of boxing, because boxing can be the biggest performance hit. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: 3D Points (structs vs classes)
    ... >> allocation and GC overhead and overall memory pressure) vs the time it ... using ref eliminates the copy but through the extra indirection access to ... but for larger structs it may save time, ... always awre of boxing, because boxing can be the biggest performance hit. ...
    (microsoft.public.dotnet.framework.drawing)