I made a small test program that multiplies and adds 10 million numbers. With float it always takes 51ms. With double it takes between 210 and 3310ms between compilations (3310ms happens only every 10 compilations or so). What’s going on here?
private void button1_Click(object sender, RoutedEventArgs e)
{
DateTime now = DateTime.Now;
testCalc(1f,2f,3f);
System.Diagnostics.Debug.Print((DateTime.Now-now).TotalMilliseconds.ToString());
now = DateTime.Now;
testCalcDouble(1, 2, 3);
System.Diagnostics.Debug.Print((DateTime.Now - now).TotalMilliseconds.ToString());
}
private void testCalc(float a, float b, float c)
{
for (int i = 0; i < 10000000; i++)
{
a++;
c--;
float d = (a + b) * c;
}
}
private void testCalcDouble(double a, double b, double c)
{
for (int i = 0; i < 10000000; i++)
{
a++;
c--;
double d = (a + b) * c;
}
}
Question closed: it only happens while running in the debugger