tolmasky / language

A fast PEG parser written in JavaScript with first class errors
languagejs.com
MIT License
411 stars 48 forks source link

Slow parse times #18

Open ide opened 12 years ago

ide commented 12 years ago

I haven't done any profiling so this is a rather generic issue, but the parser performance is rather slow. For example:

> function benchmark() {
... var jquery = require('fs').readFileSync('./jquery-1.7.1.js', 'utf-8');
... console.time('parse');
... parser.parse(jquery);
... console.timeEnd('parse');
... }
> benchmark()
parse: 12042ms

I'm surprised because the theoretical performance should be quite high so I'm guessing that high number of object allocations, especially for the deep expression productions (how many nodes does it take to represent a simple string literal?) is hurting performance.

tolmasky commented 12 years ago

Are you on aim? I've done a lot research regarding this and it's easier to explain there.

Sent from my iPhone

On Feb 4, 2012, at 3:15 PM, James Idereply@reply.github.com wrote:

I haven't done any profiling so this is a rather generic issue, but the parser performance is rather slow. For example:

> function benchmark() {
... var jquery = require('fs').readFileSync('./jquery-1.7.1.js', 'utf-8');
... console.time('parse');
... parser.parse(jquery);
... console.timeEnd('parse');
... }
> benchmark()
parse: 12042ms

I'm surprised because the theoretical performance should be quite high so I'm guessing that high number of object allocations, especially for the deep expression productions (how many nodes does it take to represent a simple string literal?) is hurting performance.


Reply to this email directly or view it on GitHub: https://github.com/tolmasky/language/issues/18

ide commented 12 years ago

Sure, my SN is chocoflyer.

anodos commented 12 years ago

I'm curious what the latest is here. I am interesting in faster parses. Even a little pointer in the right direction might help with optimization.

dongli commented 11 years ago

I have tried Ruby PEG parser generator Parslet, and it takes around 10 seconds to parse a Fortran code with 2000+ lines. This is really slow. So what about this Language.js?