New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve generator performance #3283
Conversation
Current coverage is
|
* Find a token between start and end. | ||
*/ | ||
|
||
_findToken(test, start, end) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add type annotations?
This is awesome! I'm excited for this. Mostly looks good just a couple of suggestions/questions |
ok, will merge tomorrow. Do you have any more ideas for optimizations? (this is awesome) |
@amasad not now, but I'll keep finding performance issues in the code base : ) |
Maybe we should add some perf metrics whenever we updated some of the packages like babylon/babel-generator like in https://phabricator.babeljs.io/T6884#70050? Unless we want to bring in a larger file, the largest built file we have is |
@hzoo agree, we can add some identity test case and measure the running time for each package. like escodegen's identity test |
Thank you @gzzhanghao, you're amazing! |
Would it be possible to run a perf.js test on a PR (would be cool to get a comment on the PR like code coverage)? Or we could do it in between releases too. We can test the parser on different files/libraries, and then the generation? |
Since we are using array-style access on a string, do we need worry about multi-byte characters, ex: Chinese, Emoji. I'm not super familiar with Babel's code-base, so that may already be broken, or not something we need to concern ourselves with. A test would be great, if we don't have one yet. |
Rob: good point, can you please follow up with a task? |
I think this would be a descent test Existing working multi-byte: |
@robcolburn if we don't have a test for it already we'd appreciate a PR for some! |
@hzoo I didn't see a test for it, so I PR'd a few to @gzzhanghao branch - https://github.com/gzzhanghao/babel/pull/1 |
@robcolburn Thanks, going to merge this, so can you PR to master instead? |
This PR aims to fix the performance issue for babel-generator, see T6884.
Here is the result from the same app in the discussion.