• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Timing puzzle (was Release Build Fails)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Timing puzzle (was Release Build Fails) (From: Michael McLaughlin <email@hidden>)

  • Prev by Date: Re: backtrace() alternative?
  • Next by Date: Re: Timing puzzle (was Release Build Fails)
  • Previous by thread: Re: Timing puzzle (was Release Build Fails)
  • Next by thread: Re: Timing puzzle (was Release Build Fails)
  • Index(es):
    • Date
    • Thread