Go and generic programming on reddit, also touches on D
Robert Jacques
sandford at jhu.edu
Tue Sep 20 19:55:35 PDT 2011
On Tue, 20 Sep 2011 14:01:05 -0400, Timon Gehr <timon.gehr at gmx.ch> wrote:
[snip]
> Thank you for making this more meaningful! I assumed the standard
> library benchmark function would take care of those things. Should it?
Yes and no. Benchmark provides a good way to make a single measurement of a function, as for really short functions you do have to loop many times to be able to get a reliable reading. However, actual benchmarking requires a) tuning the benchmark() call time to about 10-20 ms and b) running benchmark() many times, taking the minimum. The idea is that on any given run you could hit a context switch, etc. so if you make multiple run, one will get lucky and not be interrupted. Worse, if a core switch happens between StopWatch start and end, the number of ticks returned is random. Hence, the comment to manually limit execution to a single core. So, it might be nice if benchmark() also took a second parameter, denoting the number of times to benchmark the function and had some better documentation on how to do good benchmarking.
More information about the Digitalmars-d
mailing list