Review of Andrei's std.benchmark
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sat Sep 22 07:50:55 PDT 2012
On 9/19/12 3:13 AM, Jacob Carlborg wrote:
> On 2012-09-17 23:13, Jens Mueller wrote:
>
>> Post all feedback to this thread. Constructive feedback is very much
>> appreciated.
>>
>> To conclude in more Andrei like words: Happy destruction!
>
> * Why is "scheduleForBenchmarking" a string? Can't it be a template mixin?
Good point, I'll look into it.
> * What's the most appropriate way of just timing a block of code?
> Something like this:
>
> auto time = benchmark!({ /* some code */ })(1);
>
> If that's the case then I suggest setting a default value of "1" for the
> "n" parameter.
A default value of n would depend on the speed of the function and the
granularity of the system's timer. That overload of benchmark is
imperfect (rather rigid) but we must keep it for backwards compatibility.
> * If I want to format the printed result differently, say in HTML, how
> would I do that? Should I use the "benchmark" function and iterate the
> BenchmarkResult array?
That is correct. printBenchmarks() does not use any magic - it just
looks at that same array.
> * BTW why doesn't benchmark return the BenchmarkResult array?
Will look into it.
> * Is this module so important to keep it as a top level module? I'm
> thinking something like a utility package or a time/date package. How
> about std.util.benchmark?
Not sure.
Andrei
More information about the Digitalmars-d
mailing list