Alex Klein
2005-05-09 19:19:13 UTC
Hi guys,
I've just started reading through the code and in order to understand it
I thought I try to profile and optimize it. Here's a little patch to
improve the performance a bit, about 7% on a small test scene I used.
For now I just restricted myself to reorganizing the
photonLight_t::illuminate(...) method. Here is what I did:
-added some const operators here and there (makes life easier for the
compiler to optimize the code)
-moved some computations such that they are executed just before they
are needed (lazy evaluation, better caching/optimization)
-set the vector to K elements at the beginning. This should completely
avoids reallocations
-reduce number of vector push/pop operations used
-replaced sqrt call by a compile-time constant
In addition, there are a few const operators in other files to make
optimization easier for the compiler.
The speed gain is not great, but hey, its free as the new version should
(and does in my test case ... maybe someone should use another scene to
test it just to be sure) produce the same results as the old one.
By the way, how far along is the refactorization? Does it make sense for
me to read through the code, suggest some further improvements and start
writing some doxygen comments in it? By the way, are you planning on
using doxygen? There is a conf-file in the CVS but there are hardly any
doxy-comments in the source...
Cheers
AlexK
P.S.: Hope the patch is in the right format, first time I've ever
submitted a patch to an open source project... :)
I've just started reading through the code and in order to understand it
I thought I try to profile and optimize it. Here's a little patch to
improve the performance a bit, about 7% on a small test scene I used.
For now I just restricted myself to reorganizing the
photonLight_t::illuminate(...) method. Here is what I did:
-added some const operators here and there (makes life easier for the
compiler to optimize the code)
-moved some computations such that they are executed just before they
are needed (lazy evaluation, better caching/optimization)
-set the vector to K elements at the beginning. This should completely
avoids reallocations
-reduce number of vector push/pop operations used
-replaced sqrt call by a compile-time constant
In addition, there are a few const operators in other files to make
optimization easier for the compiler.
The speed gain is not great, but hey, its free as the new version should
(and does in my test case ... maybe someone should use another scene to
test it just to be sure) produce the same results as the old one.
By the way, how far along is the refactorization? Does it make sense for
me to read through the code, suggest some further improvements and start
writing some doxygen comments in it? By the way, are you planning on
using doxygen? There is a conf-file in the CVS but there are hardly any
doxy-comments in the source...
Cheers
AlexK
P.S.: Hope the patch is in the right format, first time I've ever
submitted a patch to an open source project... :)