RE: [GD-Windows] VC.NET 'Optimization'
Brought to you by:
vexxed72
From: Ken N. <kn...@wh...> - 2005-04-11 15:41:30
|
Yeah, I have and there is no immediate fix around this unless you want to turn all optimizations off(hence the reason it works fine in debug mode).=20 -Ken Noland -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of yogiwp Sent: Monday, April 11, 2005 9:47 AM To: gam...@li... Subject: [GD-Windows] VC.NET 'Optimization' Hi all, I've just waste alot of time debugging, and surprised that the root of problem come from VC.NET 2003 reordering stuff too aggresively. This piece of code is supposed to measure time spent in fibonacci(): ---------------------------------------------------- timer.Restart(); int fib =3D fibonacci( 42 ); float msTime =3D timer.GetElapsed(); printf( "time=3D%f, result=3D%d\n", msTime, fib ); ---------------------------------------------------- But the optimizer decided to move the fibonacci() call just before printf() and after GetElapsed(), causing the timer to measure nothing. Of course the bug does not manifest in debug builds, which made my head hurt even more :( The fix is simply changing the last line to: printf( "time=3D%f, result=3D%d\n", timer.GetElapsed(), fib ); Anyone got bitten by this before? This is a bug, right? Yogi Wahyu Prasidha ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=3D6595&alloc_id=3D14396&op=3Dclick _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=3D555 |