http://d.puremagic.com/issues/show_bug.cgi?id=5198
Summary: Appender much slower when appending ranges of elements than individual elements Product: D Version: D2 Platform: Other OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: schvei...@yahoo.com --- Comment #0 from Steven Schveighoffer <schvei...@yahoo.com> 2010-11-10 11:23:42 PST --- Given an appender Appender!string a, the following code should be roughly equivalent performance-wise: a.put(' '); a.put(" "); But as shown by this code, the version that puts an individual character is an order of magnitude faster. import std.stdio; import std.date; import std.array; void f0() { Appender!string a; a.reserve(100_000_000); foreach(i; 0 .. 100_000_000) { a.put(' '); } } void f1() { Appender!string a; a.reserve(100_000_000); foreach(i; 0 .. 100_000_000) { a.put(" "); } } void main() { auto r = benchmark!(f0)(1); writeln(r, "ms"); r = benchmark!(f1)(1); writeln(r, "ms"); } Results: [2433]ms [13276]ms Swapping the order of testing does not change the situation. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------