It's kind of the heart of the problem and tradeoff of using lookup tables: the gains heavily depend on the context, how often they're actually used inside of a bigger program, etc. If they're slightly too big you're in for a ton of cache misses and it's a disaster. This is partially why they're only moderately used in most standard implementations, which prefer more robust and predictable (but also more complex) methods that will behave the same in most if not all cases.
That the most up voted comment here is generalizing saying not to use look up tables, without giving real benchmarks, because cache misses is embarrassing. Is the first optimization most people do when CPU bound and every game uses it in one way or another, graphics, audio, trigonometry.
I have made test.
In my case with 44100 calls per second per instance with 50 instances a Lut was 3 times faster than with sin.
3
u/mttlb Jul 20 '20
It's kind of the heart of the problem and tradeoff of using lookup tables: the gains heavily depend on the context, how often they're actually used inside of a bigger program, etc. If they're slightly too big you're in for a ton of cache misses and it's a disaster. This is partially why they're only moderately used in most standard implementations, which prefer more robust and predictable (but also more complex) methods that will behave the same in most if not all cases.