-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Speed up tree collection builder flattening when expanding keys #8774
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
Conversation
Build successful! 🎉 |
} | ||
|
||
const treeData = generateTreeData(); | ||
console.log(`Total items: ${totalItems}`); |
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.
Best way to test this is to the root level visitNode
in timing, I didn't include it so that the tests would all pass and we'd get a build, the delay/difference should be noticeable in the build, but just if you want numbers to put to it.
let startTime = Date.now();
for (let node of collection) {
visitNode(node);
}
let endTime = Date.now();
console.log(`Time taken: ${endTime - startTime}ms`);
Build successful! 🎉 |
btw I was thinking a while ago that it might be possible to do the flattening incrementally instead of copying the whole collection up front. Basically you'd do it on demand in |
Sure, but this is still a huge savings in the meantime and wouldn't preclude us from making those changes |
Oh I didn't mean now! |
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.
Awesome!
Closes #8725
Note, this does not address initial load/render of Tree, this is just for expanded keys
✅ Pull Request Checklist:
📝 Test Instructions:
visitNode
in Tree for the expand all action takesBefore: ~20772ms
After: ~190ms
🧢 Your Project: