On Wed, 13 Apr 2022 21:58:06 GMT, XenoAmess <d...@openjdk.java.net> wrote:
>> @jmehrens what about this then? >> I think it safe now(actually this mechanism is learned from Reader) > > XenoAmess has updated the pull request incrementally with one additional > commit since the last revision: > > add jmh test/micro/org/openjdk/bench/java/io/InputStreamSkipBenchmark.java line 54: > 52: @Benchmark > 53: public long testSkip0(Data data) throws IOException { > 54: TestBaseInputStream0 testBaseInputStream = new > TestBaseInputStream0(data.inputStreamSize); Instead of creating 3 methods with identical bodies, I recommend using an enum to represent the type of buffers. An example at https://github.com/openjdk/jdk/blob/7a9844cb1cd18c18ce097741cba7db1148c83de0/test/micro/org/openjdk/bench/java/util/HashMapBench.java#L65-L71 For enum values, you can name them like `LOCAL_VARIABLE`, `FIELD`, `SOFT_REFERENCE`, which is more descriptive than current "0, 1, 2," etc. test/micro/org/openjdk/bench/java/io/InputStreamSkipBenchmark.java line 127: > 125: > 126: @Override > 127: public int read(byte[] b, int off, int len) throws IOException { I suggest we actually write into the byte array to better simulate overheads (maybe by generating a number with `ThreadLocalRandom`). Otherwise, the benchmark may have exaggerated the performance gains of large skips. To simulate overhead on each read call, you can perform some extra activity consumed by the blackhole (possibly pass jmh blackhole through input stream constructor) ------------- PR: https://git.openjdk.java.net/jdk/pull/5872