Why does wrappedGrammarRule and invokeRuleWithTry 10x the runtime in browser? #1731
-
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. What's going on and is there a way we can optimize this? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
moving to discussions |
Beta Was this translation helpful? Give feedback.
-
Hi @tyleradams Generally much of the CST building is done inside |
Beta Was this translation helpful? Give feedback.
-
Yes, it does.
There may be another thing that could affect performance which is that increasing the size of functions over a certain number of characters |
Beta Was this translation helpful? Give feedback.
-
Hello again @tyleradams I suspect the benchmark is still not fully precise. Anyhow I am not sure this is the best way to go about profiling the code, as the inspection itself can modify the performance. If you do stick to measuring via .now() calls I recommend you save the data to some global variable and |
Beta Was this translation helpful? Give feedback.
-
Also note there have been some performance upgrades to this wrapper on the master branch
|
Beta Was this translation helpful? Give feedback.
Hello again @tyleradams
I suspect the benchmark is still not fully precise.
Assuming these
JSON.stringify
calls are the culprit for the unexpected results theparseAsync--formulaWithBinaryOp
would then include the time of the last two console.logs and JSON.stringify calls from insideformulaWithBinaryOp
.Anyhow I am not sure this is the best way to go about profiling the code, as the inspection itself can modify the performance.
Have you considered trying to use the Chrome Dev Tools profiler?
If you do stick to measuring via .now() calls I recommend you save the data to some global variable and
do all the printing and calculations afterwards...