Open joegoldman2 opened 3 weeks ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 74.23%. Comparing base (
71655ce
) to head (aec213e
). Report is 340 commits behind head on main.
This PR was marked stale due to lack of activity. It will be closed in 7 days.
Re-checking - Can two http methods have the same route values?. if that happens, we will incorrectly set the display name here.
Right, so the cache key should take into account the http method.
How much performance would it gain? The new method seems to have enough if checks to counter the benefit. Plus the additional memory usage.
I did a benchmark and here is the result:
Method | HttpRoute | HttpMethod | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|---|---|
Original | _OTHER | 0.9941 ns | 0.1721 ns | 0.0094 ns | - | - | |
New_CacheKeyString | _OTHER | 1.2971 ns | 0.8686 ns | 0.0476 ns | - | - | |
New_CacheKeyTuple | _OTHER | 1.3056 ns | 0.8290 ns | 0.0454 ns | - | - | |
Original | GET | 0.9614 ns | 0.5957 ns | 0.0327 ns | - | - | |
New_CacheKeyString | GET | 0.8245 ns | 1.0305 ns | 0.0565 ns | - | - | |
New_CacheKeyTuple | GET | 0.9863 ns | 0.0562 ns | 0.0031 ns | - | - | |
Original | /resources/{id} | _OTHER | 8.8834 ns | 4.1025 ns | 0.2249 ns | 0.0068 | 64 B |
New_CacheKeyString | /resources/{id} | _OTHER | 26.0081 ns | 3.1322 ns | 0.1717 ns | 0.0076 | 72 B |
New_CacheKeyTuple | /resources/{id} | _OTHER | 19.5532 ns | 7.1305 ns | 0.3908 ns | - | - |
Original | /resources/{id} | GET | 9.0777 ns | 4.2050 ns | 0.2305 ns | 0.0068 | 64 B |
New_CacheKeyString | /resources/{id} | GET | 25.6794 ns | 3.3270 ns | 0.1824 ns | 0.0068 | 64 B |
New_CacheKeyTuple | /resources/{id} | GET | 17.8230 ns | 4.8392 ns | 0.2653 ns | - | - |
The original version is better in all cases. Either my approach isn't right, or this optimization isn't worth it.
Fixes #1759.
Changes
Introduce a static
ConcurrentDictionary
to cache the activity display name. I don't think it's worth adding an entry in the changelog for this change.For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes