feat: optimize `CachedRequestBuilder` by TimothyMakkison · Pull Request #1716 · reactiveui/refit
Navigation Menu
- Notifications You must be signed in to change notification settings
- Fork 783
Conversation
Rewrote CachedRequestBuilder to use a custom MethodTableKey value as a dictionary key instead of a concatenated string. Resulted in some modest memory savings and reduced object usage.
- Added unit tests to ensure that the dictionary key works correctly.
- On lines 48 & 49 of
CachedRequestBuilderImplementationI copy the arrays to create the dictionary key, this is to prevent the arrays being changed, breaking the dictionary. This can be removed if Refit assumes that the input arrays are not accessible to the user. - Implemented
IEquatable<MethodTableKey>, implementing my ownGetHashCodemethod. I could have used the recommendedHashCodeobject but it is not available in .NET Framework. I could copy the implementation over and use it if you want.
Original
| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|
| TaskT_Async | 16.64 us | 0.329 us | 0.885 us | 1.4038 | 0.0305 | 13.04 KB |
| TaskTLong_Async | 17.25 us | 0.343 us | 0.669 us | 1.4954 | 0.0305 | 13.82 KB |
| TaskTGeneric_Async | 18.03 us | 0.360 us | 0.592 us | 1.6479 | 0.0305 | 15.19 KB |
With changes
| Method | Mean | Error | StdDev | Gen0 | Gen1 | Allocated |
|---|---|---|---|---|---|---|
| TaskT_Async | 12.19 us | 0.241 us | 0.277 us | 1.4038 | 0.0305 | 12.92 KB |
| TaskTLong_Async | 13.26 us | 0.262 us | 0.331 us | 1.4648 | 0.0305 | 13.51 KB |
| TaskTGeneric_Async | 14.35 us | 0.286 us | 0.627 us | 1.5564 | 0.0305 | 14.49 KB |
Codecov Report
Attention: Patch coverage is 82.35294% with 6 lines in your changes missing coverage. Please review.
Project coverage is 84.57%. Comparing base (
6ebeda5) to head (70d836a).
Report is 44 commits behind head on main.
| Files | Patch % | Lines |
|---|---|---|
| Refit/CachedRequestBuilderImplementation.cs | 82.35% | 4 Missing and 2 partials ⚠️ |
Additional details and impacted files
@@ Coverage Diff @@ ## main #1716 +/- ## ========================================== - Coverage 87.73% 84.57% -3.16% ========================================== Files 33 35 +2 Lines 2348 2503 +155 Branches 294 325 +31 ========================================== + Hits 2060 2117 +57 - Misses 208 304 +96 - Partials 80 82 +2
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
github-actions
bot
locked as resolved and limited conversation to collaborators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters