On Wednesday, 24 October 2012 at 09:50:38 UTC, Era Scarecrow
wrote:
On Wednesday, 24 October 2012 at 04:49:19 UTC, 1100110 wrote:
The following takes nearly three minutes to compile.
The culprit is the line bar ~= B();
What is wrong with this?
I have the same issue on linux x64 2.060
So appending to a dynamic array isn't really that efficient.
But this goes WAY over that line. I'm timing your test now.
It's still going...
It appears it's all happening during copying init, why I am
not sure.
[code]
struct B {
enum SIZE = 1024 * 64;
int[SIZE] x;
}
//same timing issue, no array involved
void test(B b) {}
void main() {
test(B());
}
[/code]
I've changed the *64 to various numbers and gotten curious
results. The mb is the noted (estimated) memory footprint it
used during compiling.
1: 0m0.725s mb:??
2: 0m1.414s mb:??
4: 0m2.620s mb:28
8: 0m8.937s mb:30
16: 0m35.869s mb:34
32: 2m36.922s mb:42
64: 9m27.353s mb:56
According to assembly dmd just generates repetitive instructions
to zero memory instead of making it in a loop. A workaround is to
initialize array to void and then zero it in a loop.