|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Speed Comparison
I finally figured out the axes thing I've been working on, and my solution
makes heavy use of trigonometric functions. (I've also improved my previous
method of doing projection by creating a plane for each pair of axes and
using the plane equation to find relative distances, thereby skipping over
rotation and translation of the universe entirely.) Since I'm storing my
trig values in a look-up table, I was wondering if I could somehow speed
the whole thing up. The following is a little simplification. My question
is: for what values (approx.) of 'someNumber' will case 2 be faster than
case 1, if any and what other variables (if any) affect the speed, e.g. the
array dimensions / data type of lut1,2[]?
-- case 1:
for(i = 0; i < someNumber; i++) {
foo = lut1[a] * lut2[b];
}
-- case 2:
lut1a = lut1[a];
lut2b = lut2[b];
for(i = 0; i < someNumber; i++) {
foo = lut1a * lut2b;
}
Essentially, how many times do I have to dereference (That is what [] does,
with an addition, too, doesn't it?) a value in an array before it becomes
faster to assign it's value to another variable, if that would actually
speed anything up at all. In a related question (for curiosity's sake),
what would the answer be if I were using *lutPtr (without the offset of a
[] to add the addition which I get the impression it does). Is A = *pB any
slower than A = B, and how much so?
-- Neil Edelman
-- ICQ UIN: 705130
-- email: mailto:dreaded.neil@phreaker.net?subject=sig
-- home: http://members.xoom.com/dreadedneil
-- moop: http://moop.bizland.com
-- "My air-to-air missile overrides your air traffic control clearance"
=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once
To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html
|
|