[antlr-interest] attempt to compare antlr vs bison/flex performance

Minas Hambardzumyan minas at ti.com
Thu Dec 20 14:27:29 PST 2007


I guess I could compare antlr java parser with the bison version in the 
gcc compiler. I will send an update when I get some results...

One conclusion seams to be obvious though. If the speed is of essence, 
then one has to simplify the grammar definition as close to LL(1) as 
possible. Doing so though moves the grammar definition away from the 
simple to read EBNF format -- one of the most important advantages of 
using antlr. So it is up to the user to pick -- easy to use/read vs not 
os easy but fast...

Regards,
Minas.

Terence Parr wrote:
> Hi Minas. Can you try it on the Java grammar(s)? I spent a bit of time 
> making that fast.
>
> Ter
> On Dec 19, 2007, at 3:22 PM, Minas Hambardzumyan wrote:
>
>> Hello,
>>
>> In an effort to compare antlr and bison/flex parsers, I did the 
>> following exercise:
>>
>> - found and compiled bison/flex "C" language parser from the 
>> following location:
>> ftp://ftp.uu.net/usenet/net.sources/ansi.c.grammar.Z
>> - downloaded and compiled antlr3 implementation of "C" language 
>> parser from this directory in antlr3 examples:
>> antlr/examples-v3/C/C
>> - preprocessed a "C" language file and stripped it such that both 
>> parser would pass it through (mostly minor changes)
>> - compared runtime for each parser
>>
>>
>> The results of this exercise show that the antlr parser is ~9 times 
>> slower than the flex/bison parser. I have used the same version of 
>> GNU C compiler for both parsers, with exact same compile options.
>>
>> Although the grammar definitions come from different sources, I still 
>> think this exercise gives a general idea about performance 
>> differences of these parsers. Could anyone please tell me if this is 
>> an expected runtime difference or you think I could do some 
>> optimizations to get faster performance from antlr3.
>>
>> I can send the complete code I used for both parsers, or any parts of 
>> it, if necessary. Just tell me which part would be of interest.
>>
>> Thanks,
>> Minas
>



More information about the antlr-interest mailing list