|
Boost : |
Subject: Re: [boost] proposal - Statistically robust function timing for performance decisions.
From: Edward Grace (ej.grace_at_[hidden])
Date: 2009-07-27 06:34:50
Dear Mathias,
On 19 Jul 2009, at 22:15, Mathias Gaunard wrote:
> Edward Grace wrote:
>
>> I modified the example to force side-effects by making the
>> variables in
>> the loop global. Consequently it now doesn't get optimised away -
>> compilers sure are clever these days.
>
> Rather, I think you should use volatile or something, which is
> guaranteed by the C++ standard not be optimized out.
Obtaining a reliable 'fire and forget' solution to this problem is
quite important. I have played a little with boost::bind - through
the way it forwards the arguments I think the side-effect problem is
avoided.
With reference to the timer code:
ejg-timer-0.0.4.zip
available here: http://tinyurl.com/lro5ok
The attached code is timing a pair of trivial functions that simply
multiply or divide two numbers and compare to see which is fastest.
Clearly this will be data dependent. On my platform (Intel - Mac) as
expected multiplication is generally faster than division.
$ ./example_binding
Enter a number: 4
Enter another: 8
When evaluating 4*0.125 vs. 4/8
There is no practial difference between division and multiplication
The difference is : 0
$ ./example_binding
Enter a number: 5
Enter another: 7
When evaluating 5*0.142857 vs. 5/7
Multiplication is quicker than division by around: 112.795%
The difference is : 1.11022e-16
Any comments?
-ed
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk