RFR: 8299982: (bf) Buffer.checkIndex(int, int) should use Objects.checkIndex(int, int) [v2]

Brian Burkhalter bpb at openjdk.org
Wed Jan 25 20:45:37 UTC 2023


On Wed, 25 Jan 2023 20:26:18 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> Replace explicit check of indexes in `Buffer::checkIndex(int,int)` with a call to `Objects::checkIndex(int,int)` in order to improve the throughput of other methods which invoke `Buffer::checkIndex(int,int)`.
>
> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8299982: Change Objects::checkIndex to Preconditions::checkIndex; improve exception message

Performance using `Preconditions::checkIndex` instead of `Objects::checkIndex`:

**Average Execution Time of `ByteBuffer::getLong(int)` in ns/op**

| size | before  | after  |
|------|---------|--------|
|   1  |   7.728 |  6.277 |
|   2  |   8.155 |  6.678 |
|  16  |  15.517 | 13.030 |
|  64  |  34.818 | 28.673 |
| 256  | 110.963 | 83.330 |

**Average Execution Time of `ByteBuffer::putLong(int, long)` in ns/op**

| size | before  | after  |
|------|---------|--------|
|   1  |   4.872 |  3.631 |
|   2  |   5.709 |  4.294 |
|  16  |  13.828 | 10.093 |
|  64  |  330250 | 26.519 |
| 256  | 152.409 | 80.466 |

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

PR: https://git.openjdk.org/jdk/pull/12174


More information about the nio-dev mailing list