On Mon, 30 Jun 2025 23:57:45 GMT, Brett Okken <d...@openjdk.org> wrote:

> What about a benchmark which exercises the actual benefits of buffering? So 
> many very small writes to a backing OutputStream which is (artificially) 
> slow. Perhaps have an OutputStream which sleeps 1ms on every call. The write 
> out more than 8k of data in chunks of less than 8 chars at a time.

In fact, StreamEncoder has a ByteBuffer that acts as a buffer, so when 
BufferedBuffer::out is an OutputStreamWirter encoded as UTF8, there is no need 
for two layers of buffer.


class BufferedWriter {
    Writer out
}

class OutputStreamWriter {
    StreamEncoder se;
}

class StreamEncoder {
    ByteBuffer bb;
}


We often use it like this:

new BufferedWriter(new OutputStreamWriter(out, UTF_8)))

-------------

PR Comment: https://git.openjdk.org/jdk/pull/26022#issuecomment-3021227716

Reply via email to