Function to print a diamond shape
"Luís
"Luís
Sun Mar 23 07:50:03 PDT 2014
On Saturday, 22 March 2014 at 14:41:48 UTC, Jay Norwood wrote:
> The computation times of different methods can differ a lot.
> How do you suggest to measure this effectively without the
> overhead of the write and writeln output? Would a count of
> 100001 and stubs like below be reasonable, or would there be
> something else that would prevent the optimizer from getting
> too aggressive?
I used this to benchmark H. S. Teoh's calendar formatter:
version(benchmark)
{
int main(string[] args)
{
enum MonthsPerRow = 3;
auto t = benchmark!(function() {
foreach(formattedYear; iota(1800, 2000).map!(year
=> formatYear(year, MonthsPerRow)))
{
foreach(_; formattedYear){};
}
})(30);
writeln(t[0].msecs * 0.001);
return 0;
}
}
While the optimizer could probably remove all of that, it
doesn't. I also tested it against other options like walkLength,
this ended up begin the better choice.
(BTW, using joiner instead of join I was able to more than double
the performance:
https://github.com/luismarques/dcal/tree/benchmark . Once the
pipeline is made lazy end to end that will probably have even
more impact.)
More information about the Digitalmars-d-learn
mailing list