TheSwamp
Code Red => .NET => Topic started by: nobody on July 12, 2019, 11:23:31 PM
-
Is there much of a difference in speed for most applications between using float, int, double, etc anymore with the power of computers? I imagine to notice it someone would have to develop some incredible program. Am I wrong?
-
I'm curious about performance too.
But really, from an interfacing with CAD perspective, it's best just to feed CAD the type it's expecting.
-
https://lmgtfy.com/?q=speed%20difference%20with%20float%2C%20int%2C%20double%2C%20decimal%20%20in%20C%23&s=g
-
... and this will probably be enough to give you bloodshot eyes.
http://nicolas.limare.net/pro/notes/2014/12/12_arit_speed/
-
What scale are you looking at? Hundreds to thousands, probably no difference visible to the user. Hundreds of thousands to millions, larger value types will start to show a difference. Still, bad idea to get too complacent. No need to be uber optimized everywhere, but being aware makes for better, more efficient code overall.
-
I don't know how much the C# compiler optimises memory for class variables but in C/C++ it can be important to 'byte align' your variables to make them easier to access in 32/64 bit lumps but that is probably less important than how you structure your routines and bulk data (cache misses can have a ~200X speed factor hit on cpu performance!). That is, it is more efficient to grab your functions and variables and hope they fit in the cache (say L1/L2) and then run them as much as you can before retrieving the next lot of code and data.
So yes, it _can_ be important if you are coding for embedded systems or VR/Games/Animation.
Given that, unless you are trying to perform gig's of calculations at 60 frames per second then it's not worth worrying about, even if it was slower using doubles over floats we're talking milliseconds 'difference' per run of routine. If this is really important then I wouldn't be using any language that's interpreted or that runs on a VM like C#.
hth
-
Yes, they can make a huge difference if you're using SIMD, google SIMD-enabled types for .NET
SSE2 XMM registers:
four 32-bit single-precision floating point numbers
two 64-bit double-precision floating point numbers or
two 64-bit integers or
four 32-bit integers or
eight 16-bit short integers or
sixteen 8-bit bytes or characters.
Otherwise probably not, just use the type that you need