java - ANTLR4 JavaScript Target very slow -


i'm developing antlr4 javascript listener grammar.

    var _require = require;     var antlr = _require('./antlr4/index');     var javalexer = _require('./generated/javalexer');     var javaparser = _require('./generated/javaparser');     var javalistener = _require('./generated/javalistener');      declare function require(name:string);        class codeanalysis {          input: string;          constructor(input:string) {           this.input = input;           this.antlrstack();         }      private antlrstack() {       console.log(this.input);       var chars = new antlr.inputstream(this.input);       var lexer = new javalexer.javalexer(chars);       var tokens = new antlr.commontokenstream(lexer);       var parser = new javaparser.javaparser(tokens);       var listener = new javalistener.javalistener();       parser.buildparsetrees = true;       var tree = parser.compilationunit();         antlr.tree.parsetreewalker.default.walk(listener, tree);     }      public getinput() {     return this.input;     }      } 

the problem performance bad (takes on 2 min) input this:

import codescape.dogbot; public class mydogbot extends dogbot{    public void run() {      turnleft();     move();    } } 

the same grammar , same listener in java performs lot faster (>2 sec).

anybody idea why? or how fix it?

bruno

the honest truth may javascript slower language....you view analytics tools in chrome or other browser , see if there bottlenecks in antlr runtime or own few lines of code chances more javascript engine performance javascript entirely text , java compiled bytecode , run lower level using virtual machine, means bytecode executed perform faster interpretation of bytecode machine code extremely fast whilst javascript has interpreted line line executed.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -