D-Programming-Language/phobos — pull request #1221 by Kozzi11 (2013-03-24 15:38:09+00:00)
Title: Improve std.algorithm.find and std.algorithm.splitter for (d)char needle

auto message = "Some text with separators\n";
foreach(index; 0 .. 10)
{
message ~= message;
}

auto t1 = Clock.currTime();
foreach(i; 0..100_000)
{
foreach(notused; splitter(message, '\n'))
{
}
}
writeln(Clock.currTime()-t1);

BEFORE:
dmd: 1 minute, 19 secs, 651 ms, 13 μs, and 5 hnsecs
gdmd: 1 minute, 29 secs, 379 ms, 177 μs, and 4 hnsecs
ldmd2: 1 minute, 22 secs, 290 ms, 900 μs, and 8 hnsecs

AFTER:
dmd: 24 secs, 812 ms, 368 μs, and 2 hnsecs
gdmd: 30 secs, 54 ms, 426 μs, and 4 hnsecs
ldmd2: 34 secs, 849 ms, 612 μs, and 2 hnsecs

BEFORE: (-O -noboundscheck -inline -release)
dmd: 20 secs, 134 ms, 786 μs, and 9 hnsecs
gdmd: 13 secs, 679 ms, 102 μs, and 6 hnsecs
ldmd2: 9 secs, 421 ms, 65 μs, and 6 hnsecs

AFTER: (-O -noboundscheck -inline -release)
dmd: 6 secs, 204 ms, 881 μs, and 5 hnsecs
gdmd: 4 secs, 577 ms, and 784 μs
ldmd2: 6 secs, 378 ms, 638 μs, and 2 hnsecs

// test with double quotes ("\n")

dmd: 26 secs, 105 ms, 729 μs, and 3 hnsecs
gdmd: 30 secs, 641 ms, 469 μs, and 9 hnsecs
ldmd2: 35 secs, 476 ms, 544 μs, and 1 hnsec

(-O -noboundscheck -inline -release)
dmd: 7 secs, 776 ms, and 972 μs
gdmd: 4 secs, 437 ms, 760 μs, and 5 hnsecs
ldmd2: 6 secs, 297 ms, 791 μs, and 4 hnsecs