Closed Marvin-Brouwer closed 2 years ago
If it's performance centric, I don't think it's a good idea. The output destination of the final buffer is also different. If you must, I suggest you prepare an abstract layer specific to your application.
I understand that the implementation differs and performance may differ too. But that is what interfaces are for, to have a concrete implementation that is different.
In the end I'm only interested in having a builder that has Append()
AppendLine()
and Clear()
and something to pour that into a string with either Flush()
WriteTo()
CopyTo()
or ToString()
or whatever you call that.
Me having to make an abstraction for that is certainly an option. But, to me it's kind of a pity I have to in this instance.
@neuecc I managed to write some wrapper code which is just a sealed class that implements the interface I want to use and exposes some methods like Append(string)
, Append(char)
, Append(char, int)
, Clear()
and ToString()
The no-allocation does seem to be doing exactly as expected, actually it appears it's allocation anything at all!
However, as soon as I start benchmarking with a fake data set of about 93.224
unique items in a asymmetric tree like structure it seems to be hugely slower than the dotnet StringBuilder implementation.
Where normally the entire benchmark suite runs about 7-9 min, I gave up after half an hour with my current implementation. And all it did was generate some test files, it was somewhere along the file that's serializing 93.224
items to disk.
(I know it's not frozen because I put some console logs in the middle of the logic to double-check that it's doing something)
I have a hunch I may be using this library incorrectly, do you have any tips on how to troubleshoot that?
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 7 days.
Hi,
I'd like to give this library a go. However, my implementation has scenarios for both utf8 and utf16 and the implementation the receives the ZStringBuilder doesn't necessarily care about that. Because of that I'd like to accept an
IStringBuilder
to which I can pass bothUtf8ValueStringBuilder
andUtf16ValueStringBuilder
.