[antlr-interest] C++ is slower than Java?

Ric Klaren klaren at cs.utwente.nl
Mon Feb 25 03:24:30 PST 2002


Hi,

On Sun, Feb 24, 2002 at 01:23:44PM -0000, keren_jefet wrote:
> I have tested the java.g example both on Java-generated parser, and
> on Cpp-generated parser (antlr-2.7.1, buildAST=true).
> Surprisingly, I found out that the Java parser, was significantly
> faster than the Cpp one, especially when handling long java source
> files. (sometimes even 600% faster...)
>
> How can that be?
> Is this related to the specific java.g grammar definitions, or maybe
> it is true for all parsers, no matter of the grammar complexity?

Hmm strange. Ok I had a quick look now. And noted the following:

Platform specifics:

ANTLR: antlr 2.7.2a1

C++:
  g++ 2.95.3,
  Sun Ultra-60: Solaris 2.8, 1 Gigabyte of main memory, 450 MHz UltraSPARC-II CPU
  All tests on a local disc.
  Relevant compiler options: -O2 -DANTLR_SUPPORT_XML -felide-constructors
  (yields binary of 1Mb)

Java:
  java version "1.2.2"
  Solaris VM (build Solaris_JDK_1.2.2_07a, native threads, sunwjit)
  jikes version 1.11 (10 jan 2000) used as javac

- java.g java.tree.g from 2.7.1 distro. Generated parsers with 2.7.2a2.
  Test files the main antlr/java tree.
- Ported one small change from java version to C++ version.
- The C++ version of the treewalker barfs on several files. Guess there's a
  bug or something in the 2.7.2a1 C++ codegen or javacodegen. (My guess is
  the first)
- Removed the files that misparsed tested again. (this makes my results
  quite questionable I know...) But I presume that if there's no error
  reported that the whole thing gets parsed and that the difference should
  be neglectible (then again it might not..)

Java version comes down to this:

real       20.9
user       10.7
sys         6.6

C++ version to this:

real        7.1
user        6.1
sys         0.0

These results are may vary one or two tenth per number between runs. So I
don't see the behaviour you do, not even the slightest indication of it.
You might post some more specifics on your testrig. Feel free to mail me
your testfiles and I'll run them here.

Ric

PS Oh yah and I had my xmms still playing Tristania's World of Glass album
which is btw very enjoyable ;)
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- klaren at cs.utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
     Human beings, who are almost unique in having the ability to learn
   from the experience of others, are also remarkable for their apparent
         disinclination to do so. --- Douglas Adams, Last Chance to See


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list