This implements an API to return the byte length of a String encoded in a given
charset. See [JDK-8372353](https://bugs.openjdk.org/browse/JDK-8372353) for
background.
---
Benchmark (encoding) (stringLength) Mode Cnt
Score Error Units
StringLoopJmhBenchmark.getBytes ASCII 10 thrpt 5
406782650.595 ± 16960032.852 ops/s
StringLoopJmhBenchmark.getBytes ASCII 100 thrpt 5
172936926.189 ± 4532029.201 ops/s
StringLoopJmhBenchmark.getBytes ASCII 1000 thrpt 5
38830681.232 ± 2413274.766 ops/s
StringLoopJmhBenchmark.getBytes ASCII 100000 thrpt 5
458881.155 ± 12818.317 ops/s
StringLoopJmhBenchmark.getBytes LATIN1 10 thrpt 5
37193762.990 ± 3962947.391 ops/s
StringLoopJmhBenchmark.getBytes LATIN1 100 thrpt 5
55400876.236 ± 1267331.434 ops/s
StringLoopJmhBenchmark.getBytes LATIN1 1000 thrpt 5
11104514.001 ± 41718.545 ops/s
StringLoopJmhBenchmark.getBytes LATIN1 100000 thrpt 5
182535.414 ± 10296.120 ops/s
StringLoopJmhBenchmark.getBytes UTF16 10 thrpt 5
113474681.457 ± 8326589.199 ops/s
StringLoopJmhBenchmark.getBytes UTF16 100 thrpt 5
37854103.127 ± 4808526.773 ops/s
StringLoopJmhBenchmark.getBytes UTF16 1000 thrpt 5
4139833.009 ± 70636.784 ops/s
StringLoopJmhBenchmark.getBytes UTF16 100000 thrpt 5
57644.637 ± 1887.112 ops/s
StringLoopJmhBenchmark.getBytesLength ASCII 10 thrpt 5
946701647.247 ± 76938927.141 ops/s
StringLoopJmhBenchmark.getBytesLength ASCII 100 thrpt 5
396615374.479 ± 15167234.884 ops/s
StringLoopJmhBenchmark.getBytesLength ASCII 1000 thrpt 5
100464784.979 ± 794027.897 ops/s
StringLoopJmhBenchmark.getBytesLength ASCII 100000 thrpt 5
1215487.689 ± 1916.468 ops/s
StringLoopJmhBenchmark.getBytesLength LATIN1 10 thrpt 5
221265102.323 ± 17013983.056 ops/s
StringLoopJmhBenchmark.getBytesLength LATIN1 100 thrpt 5
137617873.887 ± 5842185.781 ops/s
StringLoopJmhBenchmark.getBytesLength LATIN1 1000 thrpt 5
92540259.130 ± 3839233.582 ops/s
StringLoopJmhBenchmark.getBytesLength LATIN1 100000 thrpt 5
1136360.285 ± 426475.121 ops/s
StringLoopJmhBenchmark.getBytesLength UTF16 10 thrpt 5
329508584.830 ± 6277534.933 ops/s
StringLoopJmhBenchmark.getBytesLength UTF16 100 thrpt 5
86396600.366 ± 4287569.267 ops/s
StringLoopJmhBenchmark.getBytesLength UTF16 1000 thrpt 5
10037994.564 ± 779239.446 ops/s
StringLoopJmhBenchmark.getBytesLength UTF16 100000 thrpt 5
99218.929 ± 2854.843 ops/s
StringLoopJmhBenchmark.utf8LenByLoop ASCII 10 thrpt 5
409066999.717 ± 25444799.130 ops/s
StringLoopJmhBenchmark.utf8LenByLoop ASCII 100 thrpt 5
72126088.461 ± 42992009.452 ops/s
StringLoopJmhBenchmark.utf8LenByLoop ASCII 1000 thrpt 5
8300806.448 ± 533912.423 ops/s
StringLoopJmhBenchmark.utf8LenByLoop ASCII 100000 thrpt 5
87356.021 ± 7863.743 ops/s
StringLoopJmhBenchmark.utf8LenByLoop LATIN1 10 thrpt 5
356802960.574 ± 24814016.238 ops/s
StringLoopJmhBenchmark.utf8LenByLoop LATIN1 100 thrpt 5
85043539.617 ± 30538310.706 ops/s
StringLoopJmhBenchmark.utf8LenByLoop LATIN1 1000 thrpt 5
9952675.100 ± 2922230.486 ops/s
StringLoopJmhBenchmark.utf8LenByLoop LATIN1 100000 thrpt 5
79410.881 ± 50777.786 ops/s
StringLoopJmhBenchmark.utf8LenByLoop UTF16 10 thrpt 5
304196311.102 ± 20381571.060 ops/s
StringLoopJmhBenchmark.utf8LenByLoop UTF16 100 thrpt 5
84223829.681 ± 10787815.139 ops/s
StringLoopJmhBenchmark.utf8LenByLoop UTF16 1000 thrpt 5
11046224.275 ± 1200731.406 ops/s
StringLoopJmhBenchmark.utf8LenByLoop UTF16 100000 thrpt 5
112590.802 ± 3741.019 ops/s
-------------
Commit messages:
- Whitespace
- Apply suggestions from code review
- 8372353: API to compute the byte length of a String encoded in a given
Charset
Changes: https://git.openjdk.org/jdk/pull/28454/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28454&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8372353
Stats: 213 lines in 4 files changed: 213 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/28454.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28454/head:pull/28454
PR: https://git.openjdk.org/jdk/pull/28454