[Qt-interest] Parsing input and performance of QRegExp
Jens Saathoff
jensesaat at googlemail.com
Sat Jul 23 15:13:00 CEST 2011
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!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110723/4bab075b/attachment.html
More information about the Qt-interest-old
mailing list