[Issue 12069] New: ctRegex is 3x slower then R-T ?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 3 11:14:07 PST 2014


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: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 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: -------


More information about the Digitalmars-d-bugs mailing list