
Boost : 
From: Matthias Schabel (boost_at_[hidden])
Date: 20070328 16:20:09
>> Naturally, this library is demanding of the optimizer. I believe
>> someone else has verified that it is possible to achieve zero
>> overhead under Visual C++ 8.0 as well...
>
> unit_example_14.cpp passes double by value
> and quantity by reference. When I looked
> at the assembler output from msvc 8.0 it looked
> like this had a noticable effect (the quantity
> code was quite a bit more complex).
Interesting. I checked both permutations : double by const reference
and quantity by value and get
const reference :
f(x,y,z) took 4.28 seconds to run 1e+09 iterations with double =
9.34579e+08 flops
f(x,y,z) took 4.29 seconds to run 1e+09 iterations with
quantity<double> = 9.32401e+08 flops
g(x,y,z) took 4.27 seconds to run 1e+09 iterations with double =
9.36768e+08 flops
g(x,y,z) took 4.3 seconds to run 1e+09 iterations with
quantity<double> = 9.30233e+08 flops
value :
f(x,y,z) took 4.29 seconds to run 1e+09 iterations with double =
9.32401e+08 flops
f(x,y,z) took 4.28 seconds to run 1e+09 iterations with
quantity<double> = 9.34579e+08 flops
g(x,y,z) took 4.28 seconds to run 1e+09 iterations with double =
9.34579e+08 flops
g(x,y,z) took 4.28 seconds to run 1e+09 iterations with
quantity<double> = 9.34579e+08 flops
These differences look negligible to me...obviously, this depends on
the compiler/optimizer since there is no reason why there should be
any runtime cost...
Matthias
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk