-
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
JsonLayout - Reduce allocations when needing to escape string (44% time improvement) #2743
JsonLayout - Reduce allocations when needing to escape string (44% time improvement) #2743
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2743 +/- ##
=======================================
- Coverage 81% 81% -<1%
=======================================
Files 326 326
Lines 24242 24293 +51
Branches 3073 3078 +5
=======================================
+ Hits 19611 19633 +22
- Misses 3801 3829 +28
- Partials 830 831 +1 |
e8dc704
to
e9c254d
Compare
… with single StringBuilder.Append)
Think one could improve performance even more, by writing directly into the StringBuilder, and just truncate when needing to escape. |
Now there is also a good performance improvement, even when NOT having to escape strings:
|
nice, 44% improvement! |
Think one could optimize all that inherits from |
…temporary StringBuilder
dd4e66f
to
2369bd5
Compare
sound good :) |
Reuse truncated StringBuilder, instead of creating new.
Also skip the temporary StringBuilder, when using
Encode=false
. Performance optimization for nested JsonLayouts. But one can also consider usingEncode=false
for simple fields like${longdate}
or${level}
as it skips unnecessary validation.