-
Notifications
You must be signed in to change notification settings - Fork 102
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 performance of HTML generator #186
Improve performance of HTML generator #186
Conversation
src/lib/html.ts
Outdated
// Get webtreemap data to update map on bundle select | ||
let treeData = exploreResults.map<WebTreeData>((data) => ({ | ||
name: data.bundleName, | ||
data: getWebTreeMapData(data.files), | ||
})); | ||
|
||
if (treeData.length > 1) { | ||
treeData = [makeMergedTreeDataMap(cloneDeep(treeData))].concat(treeData); | ||
} | ||
const treeDataMap = { ...treeData }; | ||
const template = getFileContent(path.join(__dirname, 'tree-viz.ejs')); |
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.
- Tranforms
exploreResults
totreeData
- Adds the combined treeData ahead
- Converts array of treeData to
treeDataMap
- Then allows to combine
exploreResults
(see code below)
src/lib/html.ts
Outdated
for (const result of treeData) { | ||
const childTree = result.data; | ||
|
||
childTree._name = result.name; |
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.
Uses bundle name as the new name of child tree node.
Update snapshots using |
- Call `addSizeToTitle` after merged webTreeData is created. As a rsult `originalName` is not needed. - Add a test for `makeMergedTreeDataMap`
Thanks for your contribution! |
bundles = [ | ||
{ | ||
name: COMBINED_BUNDLE_NAME, | ||
size: formatBytes(exploreResults.reduce((total, result) => total + result.totalBytes, 0)), | ||
}, | ||
...bundles, | ||
]; |
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.
Oh wait, I think it's better if we keep bundles
as a const
, so these line could be:
bundles = [ | |
{ | |
name: COMBINED_BUNDLE_NAME, | |
size: formatBytes(exploreResults.reduce((total, result) => total + result.totalBytes, 0)), | |
}, | |
...bundles, | |
]; | |
bundles.unshift({ | |
name: COMBINED_BUNDLE_NAME, | |
size: formatBytes(exploreResults.reduce((total, result) => total + result.totalBytes, 0)), | |
}); |
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.
I'll apply this change in next commits
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.
Hey @nikolay-borzov , can you release this PR to npm? It's been a while since the last release, and I really want this to rollout my next release. (And don't forget to update the suggestion above). Many thanks.
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.
That's weird. I don't remember why I decided not to release right when this PR was merged. I will take care of it this within this week
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.
Thanks.
I think you wanted to release this PR on 2.5.0 that you're working on it, right? That's why you added this to the milestone.
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.
Yeah. And for some reason, I thought #185 will be easy to do
- Use `unshift` instead of spread operator
getWebTreeMapData
takes too much time with[combined]
bundle. In my big project, with 10000 files (max directory depth: 11) in the combined bundle, it takes ~45s, while the rest ofexploreResults
only takes 3s in total.This PR is about to move the combined bundle away from
getWebTreeMapData()
, and re-create it by merging the tree data of other bundles. The merging logic also costs ~2s in my project, but it's much less than 45s.