StringWriter delegates the writing of strings to a StringBuffer , which in turn is not faster (but slower) than a StringBuilder , since uses sync. But tests show that StringWriter faster on big data.
- 6What tests? At least they would give the link to these tests - rjhdby
|
1 answer
I do not know what this test was, but your statement is not true. I wrote a quick performance test for a single-threaded version (since StringBuilder not correctly compared in another). They showed roughly the same numbers. Why is that? Because, synchronized if used in the same thread, be in the thin stage, where the capture of the lock and its release are practically worthless.
|