• entries
46
67
• views
45485

# Awesome Progress!!

227 views

I was just going through some old code when I found a 'TrigTest' program I made to benchmark various trig approximations for a thread here a while back. Since I originally compiled it using VS 2003, I now have VS 2005, and I've heard many complaints about VS 2005's optimizer, I decided to recompile it with the same settings and see how much changed.

Before recompiling it, I ran the existing executable that was made with VS 2003, and the timing portion of the program produced the following results:
Average Execution Duration (Seconds)                    Sine = 4.805455441962594e-008            Taylor11Sine = 1.659724629806302e-008      HornerTaylor11Sine = 1.049327498327301e-008        CModestGodApprox = 4.527706733677046e-009        WildMagicApprox0 = 6.152818305119786e-009        WildMagicApprox1 = 1.049418850719854e-008     DevMasterApproxFast = 4.826987787554008e-009DevMasterApproxAccurateA = 9.475673584212519e-009DevMasterApproxAccurateR = 9.486954347549761e-009DevMasterApproxAccurateM = 9.478525902035034e-009
While the code does use templates a bit, it doesn't use anything besides simple calculation operations and a few functions from the Windows API for timing (so any new 'security features' should not affect the timing code). Thus, I was quite surprised to find that the results for the VS2005-compiled version were so vastly different:
Average Execution Duration (Seconds)                    Sine = 7.725379342905308e-008            Taylor11Sine = 1.023075111501602e-007      HornerTaylor11Sine = 8.747406444115104e-008        CModestGodApprox = 3.964541303433817e-008        WildMagicApprox0 = 1.161219847773948e-007        WildMagicApprox1 = 1.749508694540787e-007     DevMasterApproxFast = 4.910617969602283e-008DevMasterApproxAccurateA = 7.110438337833444e-008DevMasterApproxAccurateR = 7.136199153803070e-008DevMasterApproxAccurateM = 7.109845804424866e-008
The built-in 'sinf' function almost doubled in execution time, but 'WildMagicApprox0' is over 18 times slower!

If anybody is interested, you can find everything related (source, projects, executables, and assembly output for both vs 2003 and vs 2005) using this link. If there is a way to get the VS 2005 version as fast as the VS 2003 version (without modifying the vs 2003 project to make it worse =-), I'd love to know about it. The settings seem to have converted correctly as far as I could tell, but I avoid vs2005 for the most part so there could be something simple that I'm missing.

## 1 Comment

/fp:fast

or

Floating point model - fast in the optimization settings.