Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Parsing input and performance of QRegExp
Forum Updated to NodeBB v4.3 + New Features

Parsing input and performance of QRegExp

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jensen82
    wrote on 21 Jul 2011, 17:12 last edited by
    #1

    Hi!

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

    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()
    {
    list.clear();

    qDebug() << "Start\n";
    
    tgone.start();
    
    regex.setCaseSensitivity(Qt::CaseInsensitive);
    regex.setPatternSyntax(QRegExp::RegExp2);
    regex.setPattern("^(\\d{2,2})\\.(\\d{2,2})\\.(\\d{4,4})$");
    
    
    if(regex.isValid())
    {
        int i=0;
        i++;
    
        for(i=0; i<5000; i++)
        {
            if (regex.indexIn("12.03.2011") != -1)
            {
                 list.append(regex.cap(0));
                 list.append(regex.cap(1));
                 list.append(regex.cap(2));
            }
        }
    }
    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!!!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jensen82
      wrote on 24 Jul 2011, 16:25 last edited by
      #2

      no replies :-(

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

      Another thing...is there a documentation for QLALR ?

      Thanks.
      Have a nice day.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        LinusA
        wrote on 24 Jul 2011, 17:32 last edited by
        #3

        [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?
        [/quote]

        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);
        @

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jensen82
          wrote on 27 Jul 2011, 11:23 last edited by
          #4

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

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

          1 Reply Last reply
          0

          2/4

          24 Jul 2011, 16:25

          • Login

          • Login or register to search.
          2 out of 4
          • First post
            2/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved