<div dir="ltr">btw it is important to use right compiler with right flags I am using ldc with this flags<div>ldmd2 -O -release -boundscheck=off<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 9, 2017 at 6:28 PM, uncorroded via Digitalmars-d-learn <span dir="ltr"><<a href="mailto:digitalmars-d-learn@puremagic.com" target="_blank">digitalmars-d-learn@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Friday, 9 June 2017 at 14:19:48 UTC, Daniel Kozak wrote:<br>
</span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
import std.stdio;<br>
import std.array: appender, array;<br>
import std.algorithm : findSplit, splitter, joiner, canFind, map;<br></span><span class="">
import std.typecons : tuple, Tuple;<br>
import std.conv : to;<br></span><span class="">
import std.range : dropOne, dropExactly, takeExactly, chain;<br>
<br></span>
alias push_type = Tuple!(int, char[], int, bool, bool);<br>
alias npush_type = Tuple!(char[], int, char[]);<span class=""><br>
<br>
void read_log(string filename) {<br>
    File file = File(filename, "r");<br></span><div><div class="h5">
    auto npushed = appender!(npush_type[])();<br>
    auto pushed = appender!(push_type[])();<br>
    foreach (line; file.byLine) {<br>
        if (auto findResult = line.findSplit(" SYNC_PUSH: ")) {<br>
            auto rel = findResult[2];<br>
            auto att = rel.splitter(" ");<br>
<br>
            auto firstVal = <a href="http://att.front.to" rel="noreferrer" target="_blank">att.front.to</a>!int;<br>
            auto secondVal = att.dropExactly(2).takeExactly<wbr>(2).joiner("<br>
").to!(char[]).dup;<br>
            auto thirdVal = att.dropExactly(5).<a href="http://front.to" rel="noreferrer" target="_blank">front.to</a>!in<wbr>t;<br>
            auto fourthVal = findResult[2].canFind("PA-SOC_<wbr>POP");<br>
            auto fifthVal = findResult[2].canFind("CU-SOC_<wbr>POP");<br>
            pushed.put(tuple(firstVal, secondVal, thirdVal, fourthVal,<br>
fifthVal));<br>
            continue;<br>
        }<br>
        if (auto findResult = line.findSplit(" SOC_NOT_PUSHED: ")) {<br>
            auto leftPart = findResult[0].splitter(" ").dropExactly(2)<br>
                                                       .takeExactly(2);<br>
            auto rightPart = findResult[2].splitter(" ").takeExactly(2);<br>
            auto firstVal = chain(leftPart.front,<br>
leftPart.dropOne.front).to!(ch<wbr>ar[]);<br>
            auto thirdVal = <a href="http://rightPart.front.to" rel="noreferrer" target="_blank">rightPart.front.to</a>!(char[]).du<wbr>p;<br>
            auto secondVal = <a href="http://rightPart.dropOne.front.to" rel="noreferrer" target="_blank">rightPart.dropOne.front.to</a>!int<wbr>;<br>
            npushed.put(tuple(firstVal, secondVal, thirdVal));<br>
            continue;<br>
        }<br>
    }<br>
    // Doing more stuff with these arrays later. For now, just printing<br>
lengths<br>
    writeln(npushed.data.length);<br>
    writeln(pushed.data.length);<br>
}<br>
<br>
</div></div></blockquote>
<br>
Hi Daniel,<br>
<br>
Thanks a lot for the code. I tested it on our production log file and it takes 0.2 sec (50% improvement over old time)<br>
I tried using just the appender and it did not make a significant difference. On the other hand, just changing the inner loop to use std.algorithm and range seems to make a big difference.Is there a good resource to read about the good stuff in std.algorithm and range? I tried going through the library docs but they are too exhaustive!<br>
<br>
Thanks :)<br>
</blockquote></div><br></div>