Table of Contents
I'll measure the size of all of the STL containers and algorithms. This question has several dimensions: optimization, instantiation type, first vs. subsequent instantiation
Check the size of using a functor adapter rather than writing a simple function. Probably use bind() rather than a standard STL adapter since it's more flexible and will be in the next version of the standard.
I’ll also look at the performance of different argument passing conventions. Conventional wisdom is that one should pass arguments smaller than pointers by value, and larger arguments by reference. However, I suspect this fails to take into account the dereferencing penalty. The size over which an object should be passed by reference should be a function of the number of references to that object.
I can probably write this experiment using templates. something like:
template <int Size>
struct sized_object {
char data[Size];
};
template <int References, int Size>
void referring_function(const
sized_object<Size> &
obj) {
int dummy;
for(unsigned int i=0; i<References; ++i)
{
dummy = obj.data[0];
}
}
I will run my benchmarks on several different compilers so that I avoid compiler-specific effects. I do not plan to benchmark these compilers against each other. (That way I avoid problems with running them all on the same platform.) I'm just checking if different tradeoffs need to be made depending on the compiler used. Some of these compilers are not free, so I may not be able to use them.
I don't yet know what optimization flags I'll test against. I expect that I need to play around with it a bit. I expect that the flags with the most effect on all compilers will control inlining. Without inlining, I expect using templates will always make code bigger, although I don't know how much. With inlining, templates could sometimes make the code both smaller and faster.
[Veldhuizen:1997:ISCOPE] Will C++ be faster than Fortran?. Springer-Verlag. 1997. Marina del Rey, California. International Scientific Computing in Object-Oriented Parallel Environments. . http://osl.iu.edu/~tveldhui/papers/iscope97/index.html.
[Veldhuizen95b] “Expression templates”. 26-31. http://osl.iu.edu/~tveldhui/papers/Expression-Templates/exprtmpl.html. C++ Report. 5. June 1995. 1040-6042.
[Muller2000] Abstraction benchmarks and performance of C++ applications. The Fourth International Conference on Supercomputing in Nuclear Applications. September 4-7, 2000. Tokyo, Japan. . [http://www.hlrs.de/people/mueller/papers/sna2000/sna2000.ps.gz].