Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Considering the bulk of your code is <em>not</em> dealing with the 3 variables that you switched between doubles and floats, and you're talking about rather large changes in performance, I'd say that the small changes in types and tests is enough to change your cache footprint and/or register usage.</p> <p>I did some quick tests on my 32 bit machine here:</p> <pre><code>// NOTE: runnable - copy in paste into your own project class Program { static int endVal = 32768; static int runCount = 100; static void Main(string[] args) { Stopwatch doublesw = Stopwatch.StartNew(); for (int i = 0; i &lt; runCount; ++i) doubleTest(); doublesw.Stop(); Console.WriteLine("Double: " + doublesw.ElapsedMilliseconds); Stopwatch floatsw = Stopwatch.StartNew(); for (int i = 0; i &lt; runCount; ++i) floatTest(); floatsw.Stop(); Console.WriteLine("Float: " + floatsw.ElapsedMilliseconds); Console.ReadLine(); } static void doubleTest() { double value = 0; double incr = 0.001D; while (value &lt; endVal) { value += incr; } } static void floatTest() { float value = 0; float incr = 0.001f; while (value &lt; endVal) { value += incr; } } } } </code></pre> <p>and the results were:</p> <pre><code>Double: 12897 Float: 10059 </code></pre> <p>Repeated tests showed float having a clear advantage over double. Now, this is a small program, and all those variables fit within the registers.</p> <p>Unfortunately, there were enough missing parts to the code you supplied that i couldn't get a good compile and read of the assembly to see exactly what was going on exactly, but judging from my (quick) testing, this is my answer.</p> <p>(For me, the giveaway was your case #3 - adding code changes the footprint and your cache patterns - I've seen that kind of strangeness a couple times in various languages)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload