feat: refactor AppendFormattedValue in GeneratedQueryStringBuilder#2246
feat: refactor AppendFormattedValue in GeneratedQueryStringBuilder#2246TimothyMakkison wants to merge 1 commit into
AppendFormattedValue in GeneratedQueryStringBuilder#2246Conversation
013dfe8 to
2ffc0b5
Compare
|
@TimothyMakkison benchmarked this on .NET 10 - the Hybrid
|
| value / mode | this PR | hybrid |
|---|---|---|
| int / verbatim | 1.24 | 1.09 |
| int / escaped | 1.18 | 1.21 |
| long / verbatim | 1.10 | 1.02 |
| double / verbatim | 1.06 | 1.02 |
| Guid / verbatim | 0.91 | 0.87 |
Allocations: zero in all three - identical, no change either way.
|
The version in main still performs the best though. |
|
@TimothyMakkison you okay if we go for the hybrid approach documented above for this one. Yes it's a little less performant then the version in main, but, I think it combines the easier maintainability you introduced in this PR |
|
Thanks @TimothyMakkison! I've folded your feedback into |
|
Sorry, never got round to replying, happy you merged. Had been meaning to write my own benchmarks like yours to compare the approaches, as I was surprised by the differences and wanted to know how many ns each operation took. I assume all of the slow down is caused by the instantiation of the I do wonder if it is worth decreasing the size of the initial I've been meaning to mention this along with the prospect of using
https://www.meziantou.net/csharp-9-improve-performance-using-skiplocalsinit.htm |

Refactor
AppendFormattedValueto useValiueStringBuilderand inlineFormatWithGrowth