-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Performance: Counter/ProcessId/ThreadId-LayoutRenderer allocates less memory #1695
Performance: Counter/ProcessId/ThreadId-LayoutRenderer allocates less memory #1695
Conversation
87007b6
to
44e867d
Compare
Current coverage is 80% (diff: 100%)@@ master #1695 diff @@
==========================================
Files 274 274
Lines 16871 16905 +34
Methods 2666 2669 +3
Messages 0 0
Branches 1871 1875 +4
==========================================
+ Hits 13511 13543 +32
- Misses 2928 2929 +1
- Partials 432 433 +1
|
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.
What kind of garbage are we talking about? Garbage collector garbage?
|
||
// Calculate length of integer when written out | ||
int length; | ||
if (value >= 10000) |
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.
uhm, what about value / 10
?
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.
Less-than should be faster than division, and requires fewer iterations when larger values.
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.
But I can revert, when testing then the profiler never picked up the ThreadIdLayoutRenderer whether using division-loop or if-less-than
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 sounds like a premature optimization? Also we have now more less-than operations needed. My proposal is to replace the whole block with a single division (and some rounding up or down, dunno)
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.
Have removed the optimization and squashed the commits
[InlineData(1234567890)] | ||
[InlineData(int.MaxValue)] | ||
[InlineData(int.MinValue)] | ||
void TestAppendInvariant(int input) |
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.
we're missing negative numbers?
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.
They are inside the test-method. I subtract the value from 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.
missed that. Maybe rename the method?
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.
Have no special opinion. Have a good method 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.
TestAppendInvariant_positive_and_negative :P
Changed the title from without garbage to without allocation |
c5d8791
to
182c9dd
Compare
PS: I'm renaming the PRs so it is more suitable for the changelog. |
These three renderers are using the invariant culture. - StringBuilder Append without allocation
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)