RFR: 8254078: DataOutputStream is very slow post-disabling of Biased Locking [v4]
Aleksey Shipilev
shade at openjdk.java.net
Mon Oct 12 18:24:15 UTC 2020
On Mon, 12 Oct 2020 18:09:12 GMT, Andrew Haley <aph at openjdk.org> wrote:
>> test/micro/org/openjdk/bench/java/io/DataOutputStreamTest.java line 117:
>>
>>> 115: case STRING: writeString(state, dataOutput); break;
>>> 116: }
>>> 117: }
>>
>> So, the way I see it, this can be replaced by:
>>
>> public void write(DataOutput dataOutput) {
>> switch (basicType) {
>> case CHAR:
>> for (int i = 0; i < SIZE; i += 2) {
>> dataOutput.writeChar(i);
>> }
>> break;
>> case SHORT:
>> for (int i = 0; i < SIZE; i += 2) {
>> dataOutput.writeShort(i);
>> }
>> break;
>> case INT:
>> for (int i = 0; i < SIZE; i += 4) {
>> dataOutput.writeInt(i);
>> }
>> break;
>> case STRING:
>> dataOutput.writeChars(state.outputString);
>> break;
>> }
>> }
>>
>> ...thus keeping all the code in one place, and simplifying the benchmark.
>
> I didn't quite do that, preferring to keep the writeX functions separate.
No problem, this is a question of personal style. If this was a very fine-grained benchmark, we would worry about
inlining/dispatch costs.
-------------
PR: https://git.openjdk.java.net/jdk/pull/542
More information about the core-libs-dev
mailing list