On Tuesday, 1 May 2012 at 20:49:48 UTC, Nick Sabalausky wrote:
"jerro" <[email protected]> wrote in message
news:[email protected]...
On Tuesday, 1 May 2012 at 08:26:45 UTC, Nick Sabalausky wrote:
A little write-up I just did on something I thought was
pretty cool:
Combine Coroutines and Input Ranges for Dead-Simple D
Iteration
https://www.semitwist.com/articles/article/view/combine-coroutines-and-input-ranges-for-dead-simple-d-iteration
This is fun and all, but because of the horrible performance
we really shouldn't be recommending people to use it.
So it is bad performance?
It has bad performance compared to something like iota - I get
about 15 million iterations per second for this loop:
struct Iterable
{
alias string visitType;
void visit()
{
foreach(i; 0 .. 10_000_000)
yield(i);
}
}
...
foreach(el; visitor(i))
sum ++;
using Robert Clipsham's code, compared to billions iterations
per second with a regular loop. The problem is that people new
to D could see this, assume it performs similar to ranges like
iot and then wonder why their code is slow.