-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
UnsignedBytes.lexicographicalComparator()
use `Arrays.compareU…
…nsigned` when it's available. This provides another [alternative to using `Unsafe`](#6806). And port the benchmark to JMH, which for now means making it Google-internal. (Not that we have our _Caliper_ benchmarks actually _running_ externally, either, IIRC.) The benchmarks suggest that the old, `Unsafe`-based implementation is faster up to 64 elements or so but that it's a matter of only about a nanosecond. The new implementation pulls ahead for larger arrays, including an advantage of about 5-10 ns for 1024 elements. For now, I've included this implementation only in the JRE flavor of Guava. We could include it in the Android flavor, too, to see if it helps [under API Level 33+](https://developer.android.com/reference/java/util/Arrays#compareUnsigned(byte[],%20byte[])). But we really would want to do yet more benchmarking for that. RELNOTES=n/a PiperOrigin-RevId: 713020393
- Loading branch information
Showing
3 changed files
with
58 additions
and
112 deletions.
There are no files selected for viewing
107 changes: 0 additions & 107 deletions
107
guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters