Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Update: Providing Rule Metadata to Formatters #10
Update: Providing Rule Metadata to Formatters #10
Changes from 19 commits
9ad5dbc
9dbaa1d
a1e73e7
913614f
2edc789
9be43d1
21f470d
4deed2c
c769148
7bc936a
df56da5
3b935ee
cf257fc
2129d3f
17aaa93
a660fbd
27b2f70
7f16868
a3e3258
c3897ff
f53ba0a
685317a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 think we'd be better off using a
Map
here. It should (in theory) be more performant because we won't be changing the shape of an object by adding hundreds of keys to it.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 think an object would be better because it would be more easily serializable by formatters like
json-with-metadata
(and anyone usingjson-with-metadata
would be able to use almost the same interface as regular formatters).I suspect there wouldn't be too much of a performance impact since the final shape of the object would be roughly the same on each iteration.
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 did a simple memory usage profile and it averages about 125 KB more with this change. I analyzed the three benchmark test scripts with the default ruleset.
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.
@EasyRhinoMSFT can you clarify that a bit? Are you saying
Map
used more memory or using an object did?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.
@EasyRhinoMSFT this is the comment I referred to in my other comment. :)
I'd also like to hear a few other opinions or whether the rule meta should be in an object or a map. I'm of the mind that when we expose an object in our API that is intended to be used as a map, we should just be using a map. Most formatters will not be formatting the result as JSON, so I don't think optimizing for that case makes a lot of sense.
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 didn't actually do the Map case, just object vs. nothing. I'll profile the Map version today, though there was enough variance across trials that I doubt we'll see an appreciable difference.
The method was to look at process.memoryUsage() -- really basic and probably naive, so let me know if there is a different approach I should use. I ran trials with and without the change for each of the three bench scripts in .\tests\bench.
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.
Map is easier to insert data into, object is easier to deal with for consumers (serialization), so in my opinion, unless there's a rather large performance gain by using Map, I would go with an object.