diff options
author | Paul Duffin <paulduffin@google.com> | 2015-01-15 16:21:25 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2015-01-15 16:21:25 +0000 |
commit | 0491ff02739aaadefb6c8afac82777c4e261ce4c (patch) | |
tree | f46c5be8d52e212d97e2636d9eb51de46f566d30 /guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java | |
parent | 12f8ed0821380c1a961ced21c81d260047a7fd10 (diff) | |
download | android_external_guava-0491ff02739aaadefb6c8afac82777c4e261ce4c.tar.gz android_external_guava-0491ff02739aaadefb6c8afac82777c4e261ce4c.tar.bz2 android_external_guava-0491ff02739aaadefb6c8afac82777c4e261ce4c.zip |
Revert "Replaced usages of Unsafe in UnsignedBytes with standard Java"
This reverts commit 12f8ed0821380c1a961ced21c81d260047a7fd10.
Change-Id: Ibf356e2604050708508843968c070fb0a3f85cc1
Diffstat (limited to 'guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java')
-rw-r--r-- | guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java b/guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java index a576346..eb874f6 100644 --- a/guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java +++ b/guava-tests/benchmark/com/google/common/primitives/UnsignedBytesBenchmark.java @@ -36,6 +36,7 @@ public class UnsignedBytesBenchmark extends SimpleBenchmark { private byte[] ba3; private byte[] ba4; private Comparator<byte[]> javaImpl; + private Comparator<byte[]> unsafeImpl; // 4, 8, 64, 1K, 1M, 1M (unaligned), 64M, 64M (unaligned) //@Param({"4", "8", "64", "1024", "1048576", "1048577", "6710884", "6710883"}) @@ -55,6 +56,8 @@ public class UnsignedBytesBenchmark extends SimpleBenchmark { ba4[ba1.length - 1] = (byte) 42; javaImpl = UnsignedBytes.lexicographicalComparatorJavaImpl(); + unsafeImpl = + UnsignedBytes.LexicographicalComparatorHolder.UnsafeComparator.INSTANCE; } public void timeLongEqualJava(int reps) { @@ -65,6 +68,14 @@ public class UnsignedBytesBenchmark extends SimpleBenchmark { } } + public void timeLongEqualUnsafe(int reps) { + for (int i = 0; i < reps; ++i) { + if (unsafeImpl.compare(ba1, ba2) != 0) { + throw new Error(); // deoptimization + } + } + } + public void timeDiffLastJava(int reps) { for (int i = 0; i < reps; ++i) { if (javaImpl.compare(ba3, ba4) == 0) { @@ -73,6 +84,14 @@ public class UnsignedBytesBenchmark extends SimpleBenchmark { } } + public void timeDiffLastUnsafe(int reps) { + for (int i = 0; i < reps; ++i) { + if (unsafeImpl.compare(ba3, ba4) == 0) { + throw new Error(); // deoptimization + } + } + } + public static void main(String[] args) { /* try { |