[Issue 4412] Array capacity growth spikey and the ratio approaches 1.0
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jul 2 09:48:28 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4412
--- Comment #5 from bearophile_hugs at eml.cc 2010-07-02 09:48:24 PDT ---
This is a modified program, after a suggestion by Andrei:
import std.stdio: writeln;
void main() {
int[] array;
int* old_ptr;
foreach (i; 0 .. 100_000_000) {
array ~= i;
int* new_ptr = array.ptr;
if (array.ptr != old_ptr) {
old_ptr = array.ptr;
writeln(cast(double)array.capacity() / array.length);
}
}
}
It outputs:
3
1.75
1.875
1.9375
1.96875
1.98438
1.99219
1.98828
1.99414
3.00001
2.7305
2.60017
2.48002
2.37
It shows that when relocation happens the capacity() grows significantly. But
that grow factor looks quite large.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list