Performance of tables slower than built in?

Basile B. b2.temp at gmx.com
Wed May 22 08:25:58 UTC 2019


On Wednesday, 22 May 2019 at 00:22:09 UTC, JS wrote:
> I am trying to create some fast sin, sinc, and exponential 
> routines to speed up some code by using tables... but it seems 
> it's slower than the function itself?!?
>
> [...]

Hi, lookup tables ARE faster but the problem you have here, and 
I'm surprised that nobody noticed it so far, is that YOUR SWITCH 
LEADS TO A RUNTIME STRING COMPARISON AT RUNTIME. Just replace it 
with a static if (Method = "Linear") { /*...*/} else { /*...*/}

Also takes care to the type used. With DMD the implicit coercion 
of float and double can lead to extra conversions.

You'll directly see a 15% gain after refactoring the switch.


More information about the Digitalmars-d-learn mailing list