Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Fast Matrix

Started by Chman Oct 4, 2001 at 8:56 AM 5 replies 900+ views
Original Post
Chman
Chman
hi everybody! (sorry for my english, but i''m french) I''m a pretty good java programmer and I''m making a 3D engine... It works well (without textures) and I''m optimizing it for faster results. But I''ve a question: witch is faster ? float a[4][4] or float a[16] ??? thanks... Ch*man
snowmoon
snowmoon
It''s going to depend on the JVm and JIT in use at the time it''s run.

I would say take you #1 platform and test both and see. If you have no #1 platform or want to keep it agnostic as possible use [][] as it''s cleaner code and more likly to be optimized by newer ( and newer ) JIT engines.

Good luck.
snowmoon
snowmoon
Actually faster might include a version that uses int''s or longs as floating point is notorious for slowdowns under java.

Look up some old code on fixed floating point matrix operations.
JavaJohan
JavaJohan
Hi!

The second alternative should always be the fastest.

Why?

The reason is simple. If you take a look at the Java Virtual Machine Specifiation you get a better understanding of the problem.

My short version is;
All Java arrays are stored as Java objects. In the 1st case you have to do two searches in the object heap. In the 2nd case you only have to make one search.

I don´t see how two searches could be faster than one searh.

BTW. I have done performance test of no less than 8 different JVM´s on Solaris. All did have the same behaviour.

Regards
Johan



Johan Karlsson

Johan Karlsson
BoRReL
BoRReL
Heya,

Cool, 3D Engines in Java!
Check example of mine at www.student.tue.nl/u/e.bastianen

Gr,
BoRReL
BoRReL
BoRReL
Thanks!!

Gr,
BoRReL

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.