Skip to content

perf: Fix performance regression for generator#17627

Closed
liuxingbaoyu wants to merge 2 commits intobabel:mainfrom
liuxingbaoyu:fix-generator-perf
Closed

perf: Fix performance regression for generator#17627
liuxingbaoyu wants to merge 2 commits intobabel:mainfrom
liuxingbaoyu:fix-generator-perf

Conversation

@liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Dec 2, 2025

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

This fixes the performance regression from v7.26.3 to v7.26.5.
There is 10% performance improvement.
I've tried many methods, but none have been able to fix the performance regression based on the original logic.
These include using Object.assign once, and building a new object in the sorted order, etc.
I don't understand why the performance of methods exported from modules and methods in objects is still different even when we add them to the class prototype.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 2, 2025

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

@liuxingbaoyu
Copy link
Member Author

Object.assign(PrinterClass.prototype, deprecatedBabel7Generators, generatorFunctions);
Object.assign(PrinterClass.prototype, {...deprecatedBabel7Generators, ...generatorFunctions});
And constructing a new object and sorting its keys (like ESM exports) is still slow.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 2, 2025

Open in StackBlitz

commit: 1fb11ab

@liuxingbaoyu
Copy link
Member Author

It has been replaced by #17642.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants