Site
News
Files Visual Basic
Strings
Math
General
Properties
Memory
Methods Search
Testing Inline ASM-VB
Strings
Math
General
Memory Search
Using inline ASM
Submit!
News
Files Visual Basic
Strings
Math
General
Properties
Memory
Methods Search
Testing Inline ASM-VB
Strings
Math
General
Memory Search
Using inline ASM
Submit!
Using lookup tablesUsing lookup tables for (complex) matrix operations speed up your code.
Sin/Cos are very slow operations when they are performed repetively, compared to operations like """, "*", "+"
With a lookup table you store common, values in an array for easy lookup. I used the lookup table from Lucky's VB Gaming Site.
Please note that I'm working with degrees here... when using Radians it's more precise to keep them, and not to use a lookup table...
User contributed notes:
Code: |
on the fly % faster than Lookup | on the fly (sec) | Lookup (sec) |
181% | 0,074972 | 0,210642 |
172,8% | 0,075373 | 0,205591 |
175,4% | 0,075002 | 0,206582 |
164,1% | 0,081055 | 0,214038 |
175,5% | 0,075165 | 0,207082 |
User contributed notes:
Author: VBBR () | Date: 22:03 31/03/2004 |
It seems the graph bars are inverted here. | |
Author: Jacob Roman () | Date: 00:08 06/08/2004 |
Yeah, they are reversed man. Plus, you ARE working with radians in the lookup table. (PI * Degree/180) is the formula to work with radians. And you have a typo up there in the operations(""") | |
Author: TheShau (shauros at walla dot com) | Date: 14:08 04/08/2006 |
I dont think this counts as an efficiency trick :\ You can almost always trade memory for run time, even in the smallest code. More of a programing principle :) |