Re: Timing puzzle (was Release Build Fails)
Re: Timing puzzle (was Release Build Fails)
- Subject: Re: Timing puzzle (was Release Build Fails)
- From: "B.J. Buchalter" <email@hidden>
- Date: Wed, 10 Oct 2007 14:21:29 -0400
/** generates a random number on [0,1) with 53-bit resolution*/
inline static double to_res53(uint64_t v)
{
return v * (1.0/18446744073709551616.0L);
}
My guess is that CW is converting the (1.0/18446744073709551616.0L)
to a constant and multiplying by the constant and that gcc (Xcode) is
not doing that -- rather that it is computing the divide every time
the inline function is called.
You can disassemble both files (both IDEs provide a command to do
that) and see what the difference in the generated code is.
You can also try re-writing the code as:
const double kConversionFactor = (1.0/18446744073709551616.0L);
inline static double to_res53(uint64_t v)
{
return v * kConversionFactor;
}
If my guess is correct, this should make the two compilers behave
very similarly.
Also -- in cases like this, you should run your program with Shark to
see where it it is spending its time...
B.J. Buchalter
Metric Halo
http://www.mhlabs.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden