https://d.puremagic.com/issues/show_bug.cgi?id=12069

           Summary: ctRegex is 3x slower then R-T ?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Dmitry Olshansky <[email protected]> 2014-02-03 
11:14:04 PST ---
On behalf of Walter Bright, the benchmark:

import std.datetime;
import std.stdio;
import std.regex;

void ct()
{
    string phone = "+31 650 903 7158";
    //auto phoneReg = regex(r"^\+([1-9][0-9]*) [0-9 ]*$");
    static phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";
    auto m = match(phone, phoneReg);
    assert(m);
    assert(m.captures[0] == "+31 650 903 7158");
    assert(m.captures[1] == "31");
}

void rt()
{
    string phone = "+31 650 903 7158";
    auto phoneReg = regex(r"^\+([1-9][0-9]*) [0-9 ]*$");
    //static phoneReg = ctRegex!r"^\+([1-9][0-9]*) [0-9 ]*$";
    auto m = match(phone, phoneReg);
    assert(m);
    assert(m.captures[0] == "+31 650 903 7158");
    assert(m.captures[1] == "31");
}

void main()
{
    auto r = benchmark!(ct, rt)(1_000_000);
    writefln("ct = %s msecs, rt = %s", r[0].msecs, r[1].msecs);
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to