Important: Please read the Qt Code of Conduct -

Parsing input and performance of QRegExp

  • Hi!

    I need to parse some input. The input is a poker handhistory-file.
    You can view an example here: "":

    I need the following informations:

    • All Playernames
    • Gamenumber
    • All costs (and of each player)

    Let's say i have to get all information to put in a database and to examine the data.

    My first try was "use regular expressions" and use boost::spirit.

    I find out that regular expressions are much slower than parsing with boost::spirit. The problem with spirit is that it takes a long time to compile. Very long, but it's fast as hell!

    What would you suggest? Use another parser? QLALR?

    Can i parse the following with QLALR?
    Input1: Player raises $1 to $2 (Name: Player, amount $2)
    Input2: Player raises raises $1 to $2 (Name: Player raises, amount $2)

    And...another thing? Is it fast?

    What's with other parsers? Any experience with Ragel, Bison or something else?

    Nex thing: Performance of QRegExp!

    I did a test with the following code:

    @void MainWindow::on_btnTest_clicked()
    int i = TestRegex();
    qDebug() << "Dauerte: " << i << "\n";

    int MainWindow::TestRegex()

    qDebug() << "Start\n";
        int i=0;
        for(i=0; i<5000; i++)
            if (regex.indexIn("12.03.2011") != -1)
    qDebug() << "Elemente: " << list.count() << "\n";
    return tgone.elapsed();


    If i run the code for the first time the used time is 71 ms, on second run 400, on third 501. It grows!! But why?

    I know that other frameworks need to compile a regexe, why is there no need for QRegExp?

    Thank you very much! Im really interested in your answers!!!

  • no replies :-(

    I think this is a common problem...or not? I posted this on the mailing-list, too.

    Another there a documentation for QLALR ?

    Have a nice day.

  • [quote author="jensen82" date="1311268345"]
    If i run the code for the first time the used time is 71 ms, on second run 400, on third 501. It grows!! But why?

    This looks like you might not be resetting your timer tgone. It seems to always show the time since the first run. Could that be the issue here?

    Apart from that, memory allocation MIGHT be an issue here (but I don't think so). You could try to preallocate using:
    list.reserve(5000 * 3);

  • tgone.start(); does a reset or not?

    Anyway the distance between 1st ad 2nd run is to big...a bug?

Log in to reply