Skip to content

perf: Improve @babel/generator performance#16061

Merged
nicolo-ribaudo merged 3 commits intobabel:mainfrom
liuxingbaoyu:generator-perf
Oct 26, 2023
Merged

perf: Improve @babel/generator performance#16061
nicolo-ribaudo merged 3 commits intobabel:mainfrom
liuxingbaoyu:generator-perf

Conversation

@liuxingbaoyu
Copy link
Copy Markdown
Member

@liuxingbaoyu liuxingbaoyu commented Oct 25, 2023

Q                       A
Fixed Issues? Closes #16051
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Time consumption reduced by ~15%

PS F:\babel\benchmark\babel-generator\real-case> node .\jquery.mjs
current 1 jquery 3.6: 165 ops/sec ±0.61% (6.056ms)
current 4 jquery 3.6: 39.67 ops/sec ±0.98% (25ms)
current 16 jquery 3.6: 9.31 ops/sec ±3.4% (107ms)
current 64 jquery 3.6: 2.3 ops/sec ±1.37% (435ms)
baseline 1 jquery 3.6: 135 ops/sec ±0.71% (7.41ms)
baseline 4 jquery 3.6: 32.78 ops/sec ±2.38% (31ms)
baseline 16 jquery 3.6: 8.11 ops/sec ±0.7% (123ms)
baseline 64 jquery 3.6: 1.95 ops/sec ±1.05% (513ms)

@liuxingbaoyu liuxingbaoyu added pkg: generator PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories labels Oct 25, 2023
@babel-bot
Copy link
Copy Markdown
Collaborator

babel-bot commented Oct 25, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/55717/

Copy link
Copy Markdown
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Comment thread packages/babel-generator/src/node/index.ts Outdated
Comment thread packages/babel-generator/src/printer.ts Outdated

this._inputMap = map?._inputMap;

this._buf = new Buffer(map, this._indentChar);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we already pass String.fromCharCode(this._indentChar) here, so that then we don't have to convert it multiple times inside Buffer?

liuxingbaoyu and others added 2 commits October 26, 2023 08:24
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Copy link
Copy Markdown
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome.

@nicolo-ribaudo nicolo-ribaudo merged commit 888903e into babel:main Oct 26, 2023
@github-actions github-actions Bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 30, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jan 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: generator PR: Performance 🏃‍♀️ A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants