
On 25/05/2011 18:19, Phil Bouchard wrote:
On 5/25/2011 5:10 AM, Mathias Gaunard wrote:
This is a fairly bad way to write a benchmark, and is likely to yield somewhat incorrect results.
It is based on a fixed amount of work and returns an estimate of time.
You should bench based on an external condition, such as time, rather than making a fixed number of iterations.
You mean: it should return the amount of iterations based on a fixed interval of time. I don't think it'll be as precise.
No, it should return the median time (or better yet, the median amount of cycles) taken by a single iteration, but you should do many iterations for a fixed interval of time. This is necessary to prevent the compiler from reordering things between iterations or to unroll or optimize out the loop, since you have a non-predictable branch.