Archived

This topic is now archived and is closed to further replies.

preformance/optimisation question

This topic is 5009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

would i loose a lot of game preformence if i had a class/object for type vector, line, plane, and all mathematical objects? I would not use any trig functions as i will use look up tables. [edited by - Commander Keen on March 26, 2004 4:20:21 PM]

Share this post


Link to post
Share on other sites
All performance questions are answered by the answer:

- Use a profiler.

Write your game so it works first, then try to optimise it if you feel that you want better performance. Only optimise the slow bits.

Forget trig tables. Trig is usually fast on modern CPUs - if you are doing *SO MUCH* trig that you need trig tables to make it fast enough, your algorithm may require a review

If of course you''re targetting some tiny device with a weak CPU, there might be merit in using trig tables (Profiling on such a device may be difficult also)

Good luck.

Mark

Share this post


Link to post
Share on other sites
can u give me a more black and white answer?

i am a old fashion programmer that use to make games for the 486/pentium 1. so since games have changed so much i consider my self an amature. my system is now a P3-1GHz.

so to make thouse data types is it a definte preformence issue or my game "might" end up running fine and i may be able to get away with them?

[edited by - Commander Keen on March 26, 2004 4:35:05 PM]

Share this post


Link to post
Share on other sites
yeah go for it use classes, if your using directx, it might be better use use the d3dx math classes. yeah i know its not as cool as writing your own code. and i wrote my one math classes once too. but if you dont have the time to optimise them with the 3dnow and sse instruction sets use the d3dx classes.

good luck

Share this post


Link to post
Share on other sites
there''s no reason to make a seperate class for vector/line/plane necessarily. they''re all just a series of floats/doubles that can generally be represented by a 3 or 4 unit vector. but that aside i can''t think of any reason why having those defined on seperate classes would have any noticible effect on your engine speed.

the thing that slow most engines down are algorithmic, and not generally code. you generally only worry about the performance of your vector class at the absolute end of the coding process for your engine. before that you''ll generally be able to get huge speed increases by changing algortihms. it''s only after you''ve come up with an optimal algorithm that you need to worry about these things.

so here''s the process:

write your code
get it running
use a profiler to find bottlenecks in your engine
ask: can this be fixed with a different algorithm (9 times out of 10 the answer is yes)
change algorithms
goto use a profiler until you can''t fix things by changing algorithms

only now -> optimize your vector classes and other frequently used classes (as found by the profiler to be bottlenecks)

-me

Share this post


Link to post
Share on other sites
hi,

Whatever you do, don''t use tables on modern cpus! Modern cpu''s depend heavily on cache hits. Forcing a look up into a table may cause a cache miss and that''s where your performance will degrade.

-j

Share this post


Link to post
Share on other sites