
On 18 Jul 2009, at 07:40, joel wrote:
Add me to the bandwagon ;)
How do you handle the fact that sometimes, compiler may otpimize out benchamrk code because it has no side-effects ?
Easy. I don't! When I started this I was concerned that might happen and was quite surprised to see that the compiler (g++ 4.0.1) didn't optimise out the function. More generally, I don't think a function such as: void f(); can be considered free of side-effects unless you can guarantee that it does not access global variables (or otherwise sneakily modify state). From the prototype of a compiled function I don't see how there's any way to know this. With fully templated code it may be far more subtle since the compiler can potentially 'see' everything. That said, at the moment I want to concentrate on making the timings reliable on the assumption that problems such as you describe can be circumvented later on by someone who knows more about compilers than me! -ed