Re: 3D Points (structs vs classes)

From: Eric Gunnerson [MS] (ericgu_at_online.microsoft.com)
Date: 02/27/04


Date: Thu, 26 Feb 2004 16:59:06 -0800

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.

The tradeoff is going to be different depending on how you use your type, so
it's something you need to measure. My guess is that a 3D point will be
faster as a struct, especially if you have a ton of them.

-- 
Eric Gunnerson
Visit the C# product team at http://www.csharp.net
Eric's blog is at http://weblogs.asp.net/ericgu/
This posting is provided "AS IS" with no warranties, and confers no rights.
"Frank Hileman" <frankhil@no.spamming.prodigesoftware.com> wrote in message
news:%23UkmeVx8DHA.452@TK2MSFTNGP11.phx.gbl...
> Hello cody,
>
> We used structs instead of classes for a 3x2 float matrix. We found the
> struct much faster, especially since they have operator overloading and
> produce a lot of temp objects in complex expressions. They are a natural
fit
> for matrices, vectors, and points.
>
> In fact I think you could go even higher in size and see a speed
improvement
> for that type of abstraction.
>
> Regards,
> Frank Hileman
> Prodige Software Corporation
>
> check out VG.net: www.vgdotnet.com
> Animated vector graphics system
> Integrated VS.net graphics editor
>
>


Relevant Pages

  • Re: 3D Points (structs vs classes)
    ... To echo what Frank said, the 16 byte part is a guideline. ... to copy the struct as parameters and return types, ... The tradeoff is going to be different depending on how you use your type, ... > Animated vector graphics system ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: + itimers-fix-itimer-many-thread-hang.patch added to -mm tree
    ... struct signal_struct *sig) ... run_posix_cpu_timersdoesn't use sig, but this is matter a of taste. ... My original intent was to retain the original structure of the code but, ... Frank Mayhar ...
    (Linux-Kernel)
  • Re: 3D Points (structs vs classes)
    ... > The tradeoff is between the time taken in your type be a reference type (ie ... > to copy the struct as parameters and return types, and any boxing overhead. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: 3D Points (structs vs classes)
    ... > The tradeoff is between the time taken in your type be a reference type (ie ... > to copy the struct as parameters and return types, and any boxing overhead. ...
    (microsoft.public.dotnet.framework.performance)