Open DanskerDave opened 1 year ago
The benchmark should set both the host and the protocol host.
props.setProperty(dotJoin(MAIL, HOST), host);
props.setProperty(dotJoin(MAIL, PROTOCOL_POP3S, HOST), host);
Setting the host skips reverse DNS lookups which can slow down the first benchmark result and get cached for the second result.
That said, we can't upgrade to use transferTo internally until we drop support for JDK 8. That is in the works though.
Jason, thanks for your feedback: I've updated my Benchmark.
Good to hear JDK 8 is being phased out. (my advice to people using JDK 8 is "stop it !!" )
My tip for the next version would be JDK 17:
Until then, you could maybe inline those 11 lines.
public long transferTo(OutputStream out) throws IOException {
Objects.requireNonNull(out, "out");
long transferred = 0;
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
int read;
while ((read = this.read(buffer, 0, DEFAULT_BUFFER_SIZE)) >= 0) {
out.write(buffer, 0, read);
transferred += read;
}
return transferred;
}
@DanskerDave Thanks for the tip. Upgrading to minimum version of JDK11 will most likely happen in the current release. Once that happens I should be able to use transferTo.
org.eclipse.angus.mail.pop3.POP3Message.writeTo(OutputStream os); writes each byte individually to the OutputStream
If you precede it with... org.eclipse.angus.mail.pop3.POP3Message.getInputStream().transferTo(OutputStream os); ...both will use a byte[] Buffer.
Attached (see later) is an example. (it uses test.mailu.io which seems to be a publicly accessible Demo Mail Server)
Look for the
TODO
& switch the order ofreadMessageBytesRaw(...)
&readMessageBytesRFC822(...)
to reproduce.I would expect it to buffer its writes, rather than writing each byte individually.
Desktop:
Mail server:
Java 17 Example: