-
Notifications
You must be signed in to change notification settings - Fork 118
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
Add tree view for recent $/memoryUsage feature in clangd. #86
Conversation
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, LGTM
src/memory-usage.ts
Outdated
.filter(x => !x.startsWith('_')) | ||
.map(e => convert(m[e] as WireTree, e)) | ||
.sort((x, y) => x.total - y.total) | ||
.reverse(), |
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.
why not sort in the other way directly? (or why not sort based on title)
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.
You're right. The intention was to sort by [total, title] but I messed it up.
The code to sort by a compound key is awkward in JS, but sort() is stable, so we sort the titles first and then the totals.
src/memory-usage.ts
Outdated
interface WireTree { | ||
_self: number; | ||
_total: number; | ||
[child: string]: WireTree|number|string; |
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.
my typescript isnt so strong, but why can this be anything but WireTree ? isn't it enough to handle _self
and _total
explicitly? (and even if that's not enough, where does the string come from)
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.
_self and _total have to conform to this constraint too, unfortunately. I couldn't find a way to more precisely express the type. This is one of the reasons for mapping quickly to another type :-)
(There's a workaround involving intersection types, but they must be type
rather than interface
and type
s can't be recursive as they're just aliases).
string
is a mistake (leftover from an intermediate version where I added _title)
item.tooltip = `self=${node.self} total=${node.total}`; | ||
if (node.isFile) | ||
item.iconPath = new vscode.ThemeIcon('symbol-file'); | ||
else if (!node.children.length) |
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.
do we intentionally not set any icons for non-leaf (and non-file) nodes?
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.
Correct. This is subjective, but I couldn't find an icon that seemed to add signal rather than just visual noise.
might be worth to mention this in https://clangd.llvm.org/extensions.html |
No description provided.