Closed tyleradams closed 2 years ago
Running chevrotain 9.1.0
+chevrotain@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/chevrotain/-/chevrotain-9.1.0.tgz#ca2a811372687ad6f4d11c063cd27a26e5fbd52d" + integrity sha512-A86/55so63HCfu0dgGg3j9u8uuuBOrSqly1OhBZxRu2x6sAKILLzfVjbGMw45kgier6lz45EzcjjWtTRgoT84Q==
I'm calling and profiling calling a rule 1000x in browser and getting weird results.
I'm just evaluating 1 x 1000.So looking into it, I found this weirdness:
"name": "formulaWithBinaryOp", "children": [ { "name": "wrappedGrammarRule", "children": [ { "name": "invokeRuleWithTry", "children": [ { "name": "apply", "children": [ { "name": "formulaWithBinaryOpInternal", "children": [], "time": 365.3999992609024, "count": 3015 } ], "time": 1268.0000015497208, "count": 14101 } ], "time": 1387.3000016212463, "count": 14101 } ], "time": 1511.3000013828278, "count": 14101 } ], "time": 2953.499998807907, "count": 1001 },
formulaWithBinaryOp is a rule. The actual method "this.formulaBinaryOp", takes 2953ms total Then measuring inside wrappedGrammarRule (inside recognizer_engine.ts) , I get half that (1500) Then it's mostly small decreases within recognizer_engine.ts until I get to "impl.appy(this, args);" (https://github.com/Chevrotain/chevrotain/blob/master/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts#L241) which outside takes 1268ms but the rule method (impl) takes only 365ms!?
What's going on and is there a way we can optimize this?
moving to discussions
Running chevrotain 9.1.0
I'm calling and profiling calling a rule 1000x in browser and getting weird results.
I'm just evaluating 1 x 1000.So looking into it, I found this weirdness:
formulaWithBinaryOp is a rule. The actual method "this.formulaBinaryOp", takes 2953ms total Then measuring inside wrappedGrammarRule (inside recognizer_engine.ts) , I get half that (1500) Then it's mostly small decreases within recognizer_engine.ts until I get to "impl.appy(this, args);" (https://github.com/Chevrotain/chevrotain/blob/master/packages/chevrotain/src/parse/parser/traits/recognizer_engine.ts#L241) which outside takes 1268ms but the rule method (impl) takes only 365ms!?
What's going on and is there a way we can optimize this?