summaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
authorAurimas Liutikas <aurimas@google.com>2022-04-19 16:51:35 -0700
committerAurimas Liutikas <aurimas@google.com>2022-04-19 16:51:35 -0700
commit93554f2df46f2f3b22f9386142ea02396c1f2a0d (patch)
tree611891b936ee179b8c3f9e8a79830800dbd76e31 /benchmarks
parent75c718b2434a9003e34cb2fa3c89a1acf7449cc1 (diff)
downloadandroid-31-master.tar.gz
Test: None Change-Id: Ie45894f7a232b2a15e2439b2527ca1813f334cc5
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/AdditionBenchmark.java83
-rw-r--r--benchmarks/ArrayCopyBenchmark.java53
-rw-r--r--benchmarks/ArrayIterationBenchmark.java54
-rw-r--r--benchmarks/ArrayListIterationBenchmark.java47
-rw-r--r--benchmarks/BigIntegerBenchmark.java235
-rw-r--r--benchmarks/BufferedZipFileBenchmark.java81
-rw-r--r--benchmarks/ClassLoaderResourceBenchmark.java44
-rw-r--r--benchmarks/CloneBenchmark.java1071
-rw-r--r--benchmarks/DeepArrayOpsBenchmark.java147
-rw-r--r--benchmarks/FieldAccessBenchmark.java101
-rw-r--r--benchmarks/Foo.java24
-rw-r--r--benchmarks/GetSystemPropertyBenchmark.java60
-rw-r--r--benchmarks/HashedCollectionsBenchmark.java67
-rw-r--r--benchmarks/ImtConflictBenchmark.java1706
-rw-r--r--benchmarks/InvokeInterface.java641
-rw-r--r--benchmarks/LocaleDataBenchmark.java40
-rw-r--r--benchmarks/MethodInvocationBenchmark.java141
-rw-r--r--benchmarks/MultiplicationBenchmark.java53
-rw-r--r--benchmarks/ReferenceBenchmark.java127
-rw-r--r--benchmarks/ReferenceGetBenchmark.java58
-rw-r--r--benchmarks/SmallBigIntegerBenchmark.java65
-rw-r--r--benchmarks/StringDexCacheBenchmark.java32
-rw-r--r--benchmarks/StringIterationBenchmark.java57
-rw-r--r--benchmarks/SystemArrayCopyBenchmark.java99
-rw-r--r--benchmarks/VirtualVersusInterfaceBenchmark.java39
-rw-r--r--benchmarks/XmlParseBenchmark.java150
-rw-r--r--benchmarks/XmlSerializeBenchmark.java109
-rw-r--r--benchmarks/ZipFileBenchmark.java80
-rw-r--r--benchmarks/ZipFileReadBenchmark.java90
-rw-r--r--benchmarks/regression/AnnotatedElementBenchmark.java260
-rw-r--r--benchmarks/regression/BidiBenchmark.java81
-rw-r--r--benchmarks/regression/BigIntegerBenchmark.java49
-rw-r--r--benchmarks/regression/BitSetBenchmark.java76
-rw-r--r--benchmarks/regression/BreakIteratorBenchmark.java70
-rw-r--r--benchmarks/regression/ByteBufferBenchmark.java415
-rw-r--r--benchmarks/regression/ByteBufferBulkBenchmark.java79
-rw-r--r--benchmarks/regression/ByteBufferScalarVersusVectorBenchmark.java56
-rw-r--r--benchmarks/regression/CharacterBenchmark.java299
-rw-r--r--benchmarks/regression/CharsetBenchmark.java84
-rw-r--r--benchmarks/regression/CharsetForNameBenchmark.java44
-rw-r--r--benchmarks/regression/CharsetUtf8Benchmark.java69
-rw-r--r--benchmarks/regression/ChecksumBenchmark.java49
-rw-r--r--benchmarks/regression/CipherBenchmark.java145
-rw-r--r--benchmarks/regression/CipherInputStreamBenchmark.java77
-rw-r--r--benchmarks/regression/CollatorBenchmark.java63
-rw-r--r--benchmarks/regression/CollectionsBenchmark.java79
-rw-r--r--benchmarks/regression/DateFormatBenchmark.java53
-rw-r--r--benchmarks/regression/DecimalFormatBenchmark.java162
-rw-r--r--benchmarks/regression/DecimalFormatSymbolsBenchmark.java30
-rw-r--r--benchmarks/regression/DefaultCharsetBenchmark.java27
-rw-r--r--benchmarks/regression/DnsBenchmark.java48
-rw-r--r--benchmarks/regression/DoPrivilegedBenchmark.java72
-rw-r--r--benchmarks/regression/DoubleBenchmark.java52
-rw-r--r--benchmarks/regression/EqualsHashCodeBenchmark.java83
-rw-r--r--benchmarks/regression/ExpensiveObjectsBenchmark.java152
-rw-r--r--benchmarks/regression/FileBenchmark.java33
-rw-r--r--benchmarks/regression/FloatBenchmark.java52
-rw-r--r--benchmarks/regression/FormatterBenchmark.java131
-rw-r--r--benchmarks/regression/HostnameVerifierBenchmark.java166
-rw-r--r--benchmarks/regression/IdnBenchmark.java53
-rw-r--r--benchmarks/regression/IntConstantDivisionBenchmark.java78
-rw-r--r--benchmarks/regression/IntConstantMultiplicationBenchmark.java99
-rw-r--r--benchmarks/regression/IntConstantRemainderBenchmark.java75
-rw-r--r--benchmarks/regression/IntegerBenchmark.java148
-rw-r--r--benchmarks/regression/IntegralToStringBenchmark.java168
-rw-r--r--benchmarks/regression/JarFileBenchmark.java39
-rw-r--r--benchmarks/regression/KeyPairGeneratorBenchmark.java62
-rw-r--r--benchmarks/regression/LoopingBackwardsBenchmark.java48
-rw-r--r--benchmarks/regression/MathBenchmark.java481
-rw-r--r--benchmarks/regression/MessageDigestBenchmark.java156
-rw-r--r--benchmarks/regression/MutableIntBenchmark.java86
-rw-r--r--benchmarks/regression/NumberFormatBenchmark.java31
-rw-r--r--benchmarks/regression/PriorityQueueBenchmark.java85
-rw-r--r--benchmarks/regression/PropertyAccessBenchmark.java117
-rw-r--r--benchmarks/regression/ProviderBenchmark.java46
-rw-r--r--benchmarks/regression/R.java2540
-rw-r--r--benchmarks/regression/RandomBenchmark.java50
-rw-r--r--benchmarks/regression/RealToStringBenchmark.java126
-rw-r--r--benchmarks/regression/ReflectionBenchmark.java250
-rw-r--r--benchmarks/regression/SSLLoopbackBenchmark.java36
-rw-r--r--benchmarks/regression/SSLSocketBenchmark.java96
-rw-r--r--benchmarks/regression/SSLSocketFactoryBenchmark.java27
-rw-r--r--benchmarks/regression/SchemePrefixBenchmark.java80
-rw-r--r--benchmarks/regression/SerializationBenchmark.java218
-rw-r--r--benchmarks/regression/SignatureBenchmark.java128
-rw-r--r--benchmarks/regression/SimpleDateFormatBenchmark.java115
-rw-r--r--benchmarks/regression/StrictMathBenchmark.java386
-rw-r--r--benchmarks/regression/StringBenchmark.java45
-rw-r--r--benchmarks/regression/StringBuilderBenchmark.java140
-rw-r--r--benchmarks/regression/StringEqualsBenchmark.java267
-rw-r--r--benchmarks/regression/StringIsEmptyBenchmark.java51
-rw-r--r--benchmarks/regression/StringLengthBenchmark.java27
-rw-r--r--benchmarks/regression/StringReplaceAllBenchmark.java76
-rw-r--r--benchmarks/regression/StringReplaceBenchmark.java89
-rw-r--r--benchmarks/regression/StringSplitBenchmark.java59
-rw-r--r--benchmarks/regression/StringToBytesBenchmark.java77
-rw-r--r--benchmarks/regression/StringToRealBenchmark.java45
-rw-r--r--benchmarks/regression/ThreadLocalBenchmark.java31
-rw-r--r--benchmarks/regression/TimeZoneBenchmark.java60
-rw-r--r--benchmarks/regression/URLConnectionBenchmark.java134
-rw-r--r--benchmarks/regression/XmlEntitiesBenchmark.java72
101 files changed, 15607 insertions, 0 deletions
diff --git a/benchmarks/AdditionBenchmark.java b/benchmarks/AdditionBenchmark.java
new file mode 100644
index 0000000..5d7528b
--- /dev/null
+++ b/benchmarks/AdditionBenchmark.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * What do various kinds of addition cost?
+ */
+public class AdditionBenchmark {
+ public int timeAddConstantToLocalInt(int reps) {
+ int result = 0;
+ for (int i = 0; i < reps; ++i) {
+ result += 123;
+ }
+ return result;
+ }
+ public int timeAddTwoLocalInts(int reps) {
+ int result = 0;
+ int constant = 123;
+ for (int i = 0; i < reps; ++i) {
+ result += constant;
+ }
+ return result;
+ }
+ public long timeAddConstantToLocalLong(int reps) {
+ long result = 0;
+ for (int i = 0; i < reps; ++i) {
+ result += 123L;
+ }
+ return result;
+ }
+ public long timeAddTwoLocalLongs(int reps) {
+ long result = 0;
+ long constant = 123L;
+ for (int i = 0; i < reps; ++i) {
+ result += constant;
+ }
+ return result;
+ }
+ public float timeAddConstantToLocalFloat(int reps) {
+ float result = 0.0f;
+ for (int i = 0; i < reps; ++i) {
+ result += 123.0f;
+ }
+ return result;
+ }
+ public float timeAddTwoLocalFloats(int reps) {
+ float result = 0.0f;
+ float constant = 123.0f;
+ for (int i = 0; i < reps; ++i) {
+ result += constant;
+ }
+ return result;
+ }
+ public double timeAddConstantToLocalDouble(int reps) {
+ double result = 0.0;
+ for (int i = 0; i < reps; ++i) {
+ result += 123.0;
+ }
+ return result;
+ }
+ public double timeAddTwoLocalDoubles(int reps) {
+ double result = 0.0;
+ double constant = 123.0;
+ for (int i = 0; i < reps; ++i) {
+ result += constant;
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/ArrayCopyBenchmark.java b/benchmarks/ArrayCopyBenchmark.java
new file mode 100644
index 0000000..000782c
--- /dev/null
+++ b/benchmarks/ArrayCopyBenchmark.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.util.Arrays;
+
+public class ArrayCopyBenchmark {
+ public void timeManualArrayCopy(int reps) {
+ char[] src = new char[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ char[] dst = new char[8192];
+ for (int i = 0; i < 8192; ++i) {
+ dst[i] = src[i];
+ }
+ }
+ }
+
+ public void time_System_arrayCopy(int reps) {
+ char[] src = new char[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ char[] dst = new char[8192];
+ System.arraycopy(src, 0, dst, 0, 8192);
+ }
+ }
+
+ public void time_Arrays_copyOf(int reps) {
+ char[] src = new char[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ char[] dst = Arrays.copyOf(src, 8192);
+ }
+ }
+
+ public void time_Arrays_copyOfRange(int reps) {
+ char[] src = new char[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ char[] dst = Arrays.copyOfRange(src, 0, 8192);
+ }
+ }
+}
diff --git a/benchmarks/ArrayIterationBenchmark.java b/benchmarks/ArrayIterationBenchmark.java
new file mode 100644
index 0000000..1425ca0
--- /dev/null
+++ b/benchmarks/ArrayIterationBenchmark.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * How do various ways of iterating through an array compare?
+ */
+public class ArrayIterationBenchmark {
+ Foo[] mArray = new Foo[27];
+ {
+ for (int i = 0; i < mArray.length; ++i) mArray[i] = new Foo();
+ }
+ public void timeArrayIteration(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ int sum = 0;
+ for (int i = 0; i < mArray.length; i++) {
+ sum += mArray[i].mSplat;
+ }
+ }
+ }
+ public void timeArrayIterationCached(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ int sum = 0;
+ Foo[] localArray = mArray;
+ int len = localArray.length;
+
+ for (int i = 0; i < len; i++) {
+ sum += localArray[i].mSplat;
+ }
+ }
+ }
+ public void timeArrayIterationForEach(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ int sum = 0;
+ for (Foo a: mArray) {
+ sum += a.mSplat;
+ }
+ }
+ }
+}
diff --git a/benchmarks/ArrayListIterationBenchmark.java b/benchmarks/ArrayListIterationBenchmark.java
new file mode 100644
index 0000000..92a8e66
--- /dev/null
+++ b/benchmarks/ArrayListIterationBenchmark.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.util.ArrayList;
+
+/**
+ * Is a hand-coded counted loop through an ArrayList cheaper than enhanced for?
+ */
+public class ArrayListIterationBenchmark {
+ ArrayList<Foo> mList = new ArrayList<Foo>();
+ {
+ for (int i = 0; i < 27; ++i) mList.add(new Foo());
+ }
+ public void timeArrayListIterationIndexed(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ int sum = 0;
+ ArrayList<Foo> list = mList;
+ int len = list.size();
+ for (int i = 0; i < len; ++i) {
+ sum += list.get(i).mSplat;
+ }
+ }
+ }
+ public void timeArrayListIterationForEach(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ int sum = 0;
+ for (Foo a : mList) {
+ sum += a.mSplat;
+ }
+ }
+ }
+}
diff --git a/benchmarks/BigIntegerBenchmark.java b/benchmarks/BigIntegerBenchmark.java
new file mode 100644
index 0000000..2b78c0a
--- /dev/null
+++ b/benchmarks/BigIntegerBenchmark.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.math.BigInteger;
+
+/**
+ * Tries to measure important BigInteger operations across a variety of BigInteger sizes.
+ * Note that BigInteger implementations commonly need to use wildly different algorithms
+ * for different sizes, so relative performance may change substantially depending on the
+ * size of the integer.
+ * This is not structured as a proper benchmark; just run main(), e.g. with
+ * vogar libcore/benchmarks/src/benchmarks/BigIntegerBenchmark.java.
+ */
+public class BigIntegerBenchmark {
+ private static final boolean PRINT_TIMES = true;
+
+ private static long getStartTime() {
+ if (PRINT_TIMES) {
+ return System.nanoTime();
+ } else {
+ return 0;
+ }
+ }
+
+ private static void printTime(String s, long startTime, int reps) {
+ if (PRINT_TIMES) {
+ System.out.println(s
+ + (double)(System.nanoTime() - startTime) / 1000.0 / reps + " usecs / iter");
+ }
+ }
+
+ // A simple sum of products computation, mostly so we can check timing in the
+ // absence of any division. Computes the sum from 1 to n of ((10^prec) << 30) + 1)^2,
+ // repeating the multiplication, but not addition of 1, each time through the loop.
+ // Check the last few bits of the result as we go. Assumes n < 2^30.
+ // Note that we're actually squaring values in computing the product.
+ // That affects the algorithm used by some implementations.
+ private static void inner(int n, int prec) {
+ BigInteger big = BigInteger.TEN.pow(prec).shiftLeft(30).add(BigInteger.ONE);
+ BigInteger sum = BigInteger.ZERO;
+ for (int i = 0; i < n; ++i) {
+ sum = sum.add(big.multiply(big));
+ }
+ if (sum.and(BigInteger.valueOf(0x3fffffff)).intValue() != n) {
+ System.out.println("inner() got " + sum.and(BigInteger.valueOf(0x3fffffff))
+ + " instead of " + n);
+ }
+ }
+
+ // Execute the above rep times, optionally timing it.
+ private static void repeatInner(int n, int prec, int rep) {
+ long startTime = getStartTime();
+ for (int i = 0; i < rep; ++i) {
+ inner(n, prec);
+ }
+ printTime("inner(" + n + "," + prec + ") took ", startTime, rep);
+ }
+
+ // Approximate the sum of the first 1000 terms of the harmonic series (sum of 1/m as m
+ // goes from 1 to n) to about prec digits. The result has an implicit decimal point
+ // prec digits from the right.
+ private static BigInteger harmonic1000(int prec) {
+ BigInteger scaledOne = BigInteger.TEN.pow(prec);
+ BigInteger sum = BigInteger.ZERO;
+ for (int i = 1; i <= 1000; ++i) {
+ sum = sum.add(scaledOne.divide(BigInteger.valueOf(i)));
+ }
+ return sum;
+ }
+
+ // Execute the above rep times, optionally timing it.
+ // Check results for equality, and print one, to compaare against reference.
+ private static void repeatHarmonic1000(int prec, int rep) {
+ long startTime = getStartTime();
+ BigInteger refRes = harmonic1000(prec);
+ for (int i = 1; i < rep; ++i) {
+ BigInteger newRes = harmonic1000(prec);
+ if (!newRes.equals(refRes)) {
+ throw new AssertionError(newRes + " != " + refRes);
+ }
+ }
+ printTime("harmonic(1000) to " + prec + " digits took ", startTime, rep);
+ if (prec >= 50 && !refRes.toString()
+ .startsWith("748547086055034491265651820433390017652167916970")) {
+ throw new AssertionError("harmanic(" + prec + ") incorrectly produced " + refRes);
+ }
+ }
+
+ // Repeatedly execute just the base conversion from the last test, allowing
+ // us to time and check it for consistency as well.
+ private static void repeatToString(int prec, int rep) {
+ BigInteger refRes = harmonic1000(prec);
+ long startTime = getStartTime();
+ String refString = refRes.toString();
+ for (int i = 1; i < rep; ++i) {
+ // Disguise refRes to avoid compiler optimization issues.
+ BigInteger newRes = refRes.shiftLeft(30).add(BigInteger.valueOf(i)).shiftRight(30);
+ // The time-consuming part:
+ String newString = newRes.toString();
+ if (!newString.equals(refString)) {
+ System.out.println(newString + " != " + refString);
+ }
+ }
+ printTime("toString(" + prec + ") took ", startTime, rep);
+ }
+
+ // Compute base^exp, where base and result are scaled/multiplied by scaleBy to make them
+ // integers. exp >= 0 .
+ private static BigInteger myPow(BigInteger base, int exp, BigInteger scaleBy) {
+ if (exp == 0) {
+ return scaleBy; // Return one.
+ } else if ((exp & 1) != 0) {
+ BigInteger tmp = myPow(base, exp - 1, scaleBy);
+ return tmp.multiply(base).divide(scaleBy);
+ } else {
+ BigInteger tmp = myPow(base, exp / 2, scaleBy);
+ return tmp.multiply(tmp).divide(scaleBy);
+ }
+ }
+
+ // Approximate e by computing (1 + 1/n)^n to prec decimal digits.
+ // This isn't necessarily a very good approximation to e.
+ // Return the result, scaled by 10^prec.
+ private static BigInteger eApprox(int n, int prec) {
+ BigInteger scaledOne = BigInteger.TEN.pow(prec);
+ BigInteger base = scaledOne.add(scaledOne.divide(BigInteger.valueOf(n)));
+ return myPow(base, n, scaledOne);
+ }
+
+ // Repeatedly execute and check the above, printing one of the results
+ // to compare to reference.
+ private static void repeatEApprox(int n, int prec, int rep) {
+ long startTime = getStartTime();
+ BigInteger refRes = eApprox(n, prec);
+ for (int i = 1; i < rep; ++i) {
+ BigInteger newRes = eApprox(n, prec);
+ if (!newRes.equals(refRes)) {
+ throw new AssertionError(newRes + " != " + refRes);
+ }
+ }
+ printTime("eApprox(" + n + "," + prec + ") took ", startTime, rep);
+ if (n >= 100000 && prec >= 10 && !refRes.toString().startsWith("271826")) {
+ throw new AssertionError("eApprox(" + n + "," + prec + ") incorrectly produced "
+ + refRes);
+ }
+ }
+
+ // Test / time modPow()
+ private static void repeatModPow(int len, int rep) {
+ BigInteger odd1 = BigInteger.TEN.pow(len / 2).add(BigInteger.ONE);
+ BigInteger odd2 = BigInteger.TEN.pow(len / 2).add(BigInteger.valueOf(17));
+ BigInteger product = odd1.multiply(odd2);
+ BigInteger exponent = BigInteger.TEN.pow(len / 2 - 1);
+ BigInteger base = BigInteger.TEN.pow(len / 4);
+ long startTime = getStartTime();
+ BigInteger lastRes = null;
+ for (int i = 0; i < rep; ++i) {
+ BigInteger newRes = base.modPow(exponent, product);
+ if (i != 0 && !newRes.equals(lastRes)) {
+ System.out.println(newRes + " != " + lastRes);
+ }
+ lastRes = newRes;
+ }
+ printTime("ModPow() at decimal length " + len + " took ", startTime, rep);
+ if (!lastRes.mod(odd1).equals(base.modPow(exponent, odd1))) {
+ throw new AssertionError("ModPow() result incorrect mod odd1:" + odd1
+ + "; lastRes.mod(odd1)=" + lastRes.mod(odd1) + " vs. "
+ + "base.modPow(exponent, odd1)=" + base.modPow(exponent, odd1) + " base="
+ + base + " exponent=" + exponent);
+ }
+ if (!lastRes.mod(odd2).equals(base.modPow(exponent, odd2))) {
+ throw new AssertionError("ModPow() result incorrect mod odd2");
+ }
+ }
+
+ // Test / time modInverse()
+ private static void repeatModInverse(int len, int rep) {
+ BigInteger odd1 = BigInteger.TEN.pow(len / 2).add(BigInteger.ONE);
+ BigInteger odd2 = BigInteger.TEN.pow(len / 2).add(BigInteger.valueOf(17));
+ BigInteger product = odd1.multiply(odd2);
+ BigInteger arg = BigInteger.ONE.shiftLeft(len / 4);
+ long startTime = getStartTime();
+ BigInteger lastRes = null;
+ for (int i = 0; i < rep; ++i) {
+ BigInteger newRes = arg.modInverse(product);
+ if (i != 0 && !newRes.equals(lastRes)) {
+ System.out.println(newRes + " != " + lastRes);
+ }
+ lastRes = newRes;
+ }
+ printTime("ModInverse() at decimal length " + len + " took ", startTime, rep);
+ if (!lastRes.mod(odd1).equals(arg.modInverse(odd1))) {
+ throw new AssertionError("ModInverse() result incorrect mod odd1");
+ }
+ if (!lastRes.mod(odd2).equals(arg.modInverse(odd2))) {
+ throw new AssertionError("ModInverse() result incorrect mod odd2");
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ for (int i = 10; i <= 10_000; i *= 10) {
+ repeatInner(1000, i, PRINT_TIMES ? Math.min(20_000 / i, 3_000) : 2);
+ }
+ for (int i = 5; i <= 5_000; i *= 10) {
+ repeatHarmonic1000(i, PRINT_TIMES ? Math.min(20_000 / i, 3_000) : 2);
+ }
+ for (int i = 5; i <= 5_000; i *= 10) {
+ repeatToString(i, PRINT_TIMES ? Math.min(20_000 / i, 3_000) : 2);
+ }
+ for (int i = 10; i <= 10_000; i *= 10) {
+ repeatEApprox(100_000, i, PRINT_TIMES ? 50_000 / i : 2);
+ }
+ for (int i = 5; i <= 5_000; i *= 10) {
+ repeatModPow(i, PRINT_TIMES ? 10_000 / i : 2);
+ }
+ for (int i = 10; i <= 10_000; i *= 10) {
+ repeatModInverse(i, PRINT_TIMES ? 20_000 / i : 2);
+ }
+ }
+}
diff --git a/benchmarks/BufferedZipFileBenchmark.java b/benchmarks/BufferedZipFileBenchmark.java
new file mode 100644
index 0000000..aecf461
--- /dev/null
+++ b/benchmarks/BufferedZipFileBenchmark.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Random;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+public final class BufferedZipFileBenchmark {
+ @Param({"128", "1024", "8192", "65536"}) int compressedSize;
+ @Param({"4", "32", "128"}) int readSize;
+
+ private File file;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ System.setProperty("java.io.tmpdir", "/data/local/tmp");
+ file = File.createTempFile(getClass().getName(), ".zip");
+ file.deleteOnExit();
+
+ Random random = new Random(0);
+ ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
+ byte[] data = new byte[8192];
+ out.putNextEntry(new ZipEntry("entry.data"));
+ int written = 0;
+ while (written < compressedSize) {
+ random.nextBytes(data);
+ int toWrite = Math.min(compressedSize - written, data.length);
+ out.write(data, 0, toWrite);
+ written += toWrite;
+ }
+ out.close();
+ }
+
+ public void timeUnbufferedRead(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ ZipFile zipFile = new ZipFile(file);
+ ZipEntry entry = zipFile.getEntry("entry.data");
+ InputStream in = zipFile.getInputStream(entry);
+ byte[] buffer = new byte[readSize];
+ while (in.read(buffer) != -1) {
+ }
+ in.close();
+ zipFile.close();
+ }
+ }
+
+ public void timeBufferedRead(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ ZipFile zipFile = new ZipFile(file);
+ ZipEntry entry = zipFile.getEntry("entry.data");
+ InputStream in = new BufferedInputStream(zipFile.getInputStream(entry));
+ byte[] buffer = new byte[readSize];
+ while (in.read(buffer) != -1) {
+ }
+ in.close();
+ zipFile.close();
+ }
+ }
+}
diff --git a/benchmarks/ClassLoaderResourceBenchmark.java b/benchmarks/ClassLoaderResourceBenchmark.java
new file mode 100644
index 0000000..33666b5
--- /dev/null
+++ b/benchmarks/ClassLoaderResourceBenchmark.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import junit.framework.Assert;
+
+public class ClassLoaderResourceBenchmark {
+
+ private static final String EXISTENT_RESOURCE = "java/util/logging/logging.properties";
+ private static final String MISSING_RESOURCE = "missing_entry";
+
+ public void timeGetBootResource_hit(int reps) {
+ ClassLoader currentClassLoader = getClass().getClassLoader();
+ Assert.assertNotNull(currentClassLoader.getResource(EXISTENT_RESOURCE));
+
+ for (int rep = 0; rep < reps; ++rep) {
+ currentClassLoader.getResource(EXISTENT_RESOURCE);
+ }
+ }
+
+ public void timeGetBootResource_miss(int reps) {
+ ClassLoader currentClassLoader = getClass().getClassLoader();
+ Assert.assertNull(currentClassLoader.getResource(MISSING_RESOURCE));
+
+ for (int rep = 0; rep < reps; ++rep) {
+ currentClassLoader.getResource(MISSING_RESOURCE);
+ }
+ }
+
+}
diff --git a/benchmarks/CloneBenchmark.java b/benchmarks/CloneBenchmark.java
new file mode 100644
index 0000000..d05fb3d
--- /dev/null
+++ b/benchmarks/CloneBenchmark.java
@@ -0,0 +1,1071 @@
+/*
+ * Copyright (C) 2016 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+public class CloneBenchmark {
+ static class CloneableObject implements Cloneable {
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ static class CloneableManyFieldObject implements Cloneable {
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = new Object();
+ Object o4 = new Object();
+ Object o5 = new Object();
+ Object o6 = new Object();
+ Object o7 = new Object();
+ Object o8 = new Object();
+ Object o9 = new Object();
+ Object o10 = new Object();
+ Object o11 = new Object();
+ Object o12 = new Object();
+ Object o13 = new Object();
+ Object o14 = new Object();
+ Object o15 = new Object();
+ Object o16 = new Object();
+ Object o17 = new Object();
+ Object o18 = new Object();
+ Object o19 = new Object();
+ Object o20 = new Object();
+ Object o21 = new Object();
+ Object o22 = new Object();
+ Object o23 = new Object();
+ Object o24 = new Object();
+ Object o25 = new Object();
+ Object o26 = new Object();
+ Object o27 = new Object();
+ Object o28 = new Object();
+ Object o29 = new Object();
+ Object o30 = new Object();
+ Object o31 = new Object();
+ Object o32 = new Object();
+ Object o33 = new Object();
+ Object o34 = new Object();
+ Object o35 = new Object();
+ Object o36 = new Object();
+ Object o37 = new Object();
+ Object o38 = new Object();
+ Object o39 = new Object();
+ Object o40 = new Object();
+ Object o41 = new Object();
+ Object o42 = new Object();
+ Object o43 = new Object();
+ Object o44 = new Object();
+ Object o45 = new Object();
+ Object o46 = new Object();
+ Object o47 = new Object();
+ Object o48 = new Object();
+ Object o49 = new Object();
+ Object o50 = new Object();
+ Object o51 = new Object();
+ Object o52 = new Object();
+ Object o53 = new Object();
+ Object o54 = new Object();
+ Object o55 = new Object();
+ Object o56 = new Object();
+ Object o57 = new Object();
+ Object o58 = new Object();
+ Object o59 = new Object();
+ Object o60 = new Object();
+ Object o61 = new Object();
+ Object o62 = new Object();
+ Object o63 = new Object();
+ Object o64 = new Object();
+ Object o65 = new Object();
+ Object o66 = new Object();
+ Object o67 = new Object();
+ Object o68 = new Object();
+ Object o69 = new Object();
+ Object o70 = new Object();
+ Object o71 = new Object();
+ Object o72 = new Object();
+ Object o73 = new Object();
+ Object o74 = new Object();
+ Object o75 = new Object();
+ Object o76 = new Object();
+ Object o77 = new Object();
+ Object o78 = new Object();
+ Object o79 = new Object();
+ Object o80 = new Object();
+ Object o81 = new Object();
+ Object o82 = new Object();
+ Object o83 = new Object();
+ Object o84 = new Object();
+ Object o85 = new Object();
+ Object o86 = new Object();
+ Object o87 = new Object();
+ Object o88 = new Object();
+ Object o89 = new Object();
+ Object o90 = new Object();
+ Object o91 = new Object();
+ Object o92 = new Object();
+ Object o93 = new Object();
+ Object o94 = new Object();
+ Object o95 = new Object();
+ Object o96 = new Object();
+ Object o97 = new Object();
+ Object o98 = new Object();
+ Object o99 = new Object();
+ Object o100 = new Object();
+ Object o101 = new Object();
+ Object o102 = new Object();
+ Object o103 = new Object();
+ Object o104 = new Object();
+ Object o105 = new Object();
+ Object o106 = new Object();
+ Object o107 = new Object();
+ Object o108 = new Object();
+ Object o109 = new Object();
+ Object o110 = new Object();
+ Object o111 = new Object();
+ Object o112 = new Object();
+ Object o113 = new Object();
+ Object o114 = new Object();
+ Object o115 = new Object();
+ Object o116 = new Object();
+ Object o117 = new Object();
+ Object o118 = new Object();
+ Object o119 = new Object();
+ Object o120 = new Object();
+ Object o121 = new Object();
+ Object o122 = new Object();
+ Object o123 = new Object();
+ Object o124 = new Object();
+ Object o125 = new Object();
+ Object o126 = new Object();
+ Object o127 = new Object();
+ Object o128 = new Object();
+ Object o129 = new Object();
+ Object o130 = new Object();
+ Object o131 = new Object();
+ Object o132 = new Object();
+ Object o133 = new Object();
+ Object o134 = new Object();
+ Object o135 = new Object();
+ Object o136 = new Object();
+ Object o137 = new Object();
+ Object o138 = new Object();
+ Object o139 = new Object();
+ Object o140 = new Object();
+ Object o141 = new Object();
+ Object o142 = new Object();
+ Object o143 = new Object();
+ Object o144 = new Object();
+ Object o145 = new Object();
+ Object o146 = new Object();
+ Object o147 = new Object();
+ Object o148 = new Object();
+ Object o149 = new Object();
+ Object o150 = new Object();
+ Object o151 = new Object();
+ Object o152 = new Object();
+ Object o153 = new Object();
+ Object o154 = new Object();
+ Object o155 = new Object();
+ Object o156 = new Object();
+ Object o157 = new Object();
+ Object o158 = new Object();
+ Object o159 = new Object();
+ Object o160 = new Object();
+ Object o161 = new Object();
+ Object o162 = new Object();
+ Object o163 = new Object();
+ Object o164 = new Object();
+ Object o165 = new Object();
+ Object o166 = new Object();
+ Object o167 = new Object();
+ Object o168 = new Object();
+ Object o169 = new Object();
+ Object o170 = new Object();
+ Object o171 = new Object();
+ Object o172 = new Object();
+ Object o173 = new Object();
+ Object o174 = new Object();
+ Object o175 = new Object();
+ Object o176 = new Object();
+ Object o177 = new Object();
+ Object o178 = new Object();
+ Object o179 = new Object();
+ Object o180 = new Object();
+ Object o181 = new Object();
+ Object o182 = new Object();
+ Object o183 = new Object();
+ Object o184 = new Object();
+ Object o185 = new Object();
+ Object o186 = new Object();
+ Object o187 = new Object();
+ Object o188 = new Object();
+ Object o189 = new Object();
+ Object o190 = new Object();
+ Object o191 = new Object();
+ Object o192 = new Object();
+ Object o193 = new Object();
+ Object o194 = new Object();
+ Object o195 = new Object();
+ Object o196 = new Object();
+ Object o197 = new Object();
+ Object o198 = new Object();
+ Object o199 = new Object();
+ Object o200 = new Object();
+ Object o201 = new Object();
+ Object o202 = new Object();
+ Object o203 = new Object();
+ Object o204 = new Object();
+ Object o205 = new Object();
+ Object o206 = new Object();
+ Object o207 = new Object();
+ Object o208 = new Object();
+ Object o209 = new Object();
+ Object o210 = new Object();
+ Object o211 = new Object();
+ Object o212 = new Object();
+ Object o213 = new Object();
+ Object o214 = new Object();
+ Object o215 = new Object();
+ Object o216 = new Object();
+ Object o217 = new Object();
+ Object o218 = new Object();
+ Object o219 = new Object();
+ Object o220 = new Object();
+ Object o221 = new Object();
+ Object o222 = new Object();
+ Object o223 = new Object();
+ Object o224 = new Object();
+ Object o225 = new Object();
+ Object o226 = new Object();
+ Object o227 = new Object();
+ Object o228 = new Object();
+ Object o229 = new Object();
+ Object o230 = new Object();
+ Object o231 = new Object();
+ Object o232 = new Object();
+ Object o233 = new Object();
+ Object o234 = new Object();
+ Object o235 = new Object();
+ Object o236 = new Object();
+ Object o237 = new Object();
+ Object o238 = new Object();
+ Object o239 = new Object();
+ Object o240 = new Object();
+ Object o241 = new Object();
+ Object o242 = new Object();
+ Object o243 = new Object();
+ Object o244 = new Object();
+ Object o245 = new Object();
+ Object o246 = new Object();
+ Object o247 = new Object();
+ Object o248 = new Object();
+ Object o249 = new Object();
+ Object o250 = new Object();
+ Object o251 = new Object();
+ Object o252 = new Object();
+ Object o253 = new Object();
+ Object o254 = new Object();
+ Object o255 = new Object();
+ Object o256 = new Object();
+ Object o257 = new Object();
+ Object o258 = new Object();
+ Object o259 = new Object();
+ Object o260 = new Object();
+ Object o261 = new Object();
+ Object o262 = new Object();
+ Object o263 = new Object();
+ Object o264 = new Object();
+ Object o265 = new Object();
+ Object o266 = new Object();
+ Object o267 = new Object();
+ Object o268 = new Object();
+ Object o269 = new Object();
+ Object o270 = new Object();
+ Object o271 = new Object();
+ Object o272 = new Object();
+ Object o273 = new Object();
+ Object o274 = new Object();
+ Object o275 = new Object();
+ Object o276 = new Object();
+ Object o277 = new Object();
+ Object o278 = new Object();
+ Object o279 = new Object();
+ Object o280 = new Object();
+ Object o281 = new Object();
+ Object o282 = new Object();
+ Object o283 = new Object();
+ Object o284 = new Object();
+ Object o285 = new Object();
+ Object o286 = new Object();
+ Object o287 = new Object();
+ Object o288 = new Object();
+ Object o289 = new Object();
+ Object o290 = new Object();
+ Object o291 = new Object();
+ Object o292 = new Object();
+ Object o293 = new Object();
+ Object o294 = new Object();
+ Object o295 = new Object();
+ Object o296 = new Object();
+ Object o297 = new Object();
+ Object o298 = new Object();
+ Object o299 = new Object();
+ Object o300 = new Object();
+ Object o301 = new Object();
+ Object o302 = new Object();
+ Object o303 = new Object();
+ Object o304 = new Object();
+ Object o305 = new Object();
+ Object o306 = new Object();
+ Object o307 = new Object();
+ Object o308 = new Object();
+ Object o309 = new Object();
+ Object o310 = new Object();
+ Object o311 = new Object();
+ Object o312 = new Object();
+ Object o313 = new Object();
+ Object o314 = new Object();
+ Object o315 = new Object();
+ Object o316 = new Object();
+ Object o317 = new Object();
+ Object o318 = new Object();
+ Object o319 = new Object();
+ Object o320 = new Object();
+ Object o321 = new Object();
+ Object o322 = new Object();
+ Object o323 = new Object();
+ Object o324 = new Object();
+ Object o325 = new Object();
+ Object o326 = new Object();
+ Object o327 = new Object();
+ Object o328 = new Object();
+ Object o329 = new Object();
+ Object o330 = new Object();
+ Object o331 = new Object();
+ Object o332 = new Object();
+ Object o333 = new Object();
+ Object o334 = new Object();
+ Object o335 = new Object();
+ Object o336 = new Object();
+ Object o337 = new Object();
+ Object o338 = new Object();
+ Object o339 = new Object();
+ Object o340 = new Object();
+ Object o341 = new Object();
+ Object o342 = new Object();
+ Object o343 = new Object();
+ Object o344 = new Object();
+ Object o345 = new Object();
+ Object o346 = new Object();
+ Object o347 = new Object();
+ Object o348 = new Object();
+ Object o349 = new Object();
+ Object o350 = new Object();
+ Object o351 = new Object();
+ Object o352 = new Object();
+ Object o353 = new Object();
+ Object o354 = new Object();
+ Object o355 = new Object();
+ Object o356 = new Object();
+ Object o357 = new Object();
+ Object o358 = new Object();
+ Object o359 = new Object();
+ Object o360 = new Object();
+ Object o361 = new Object();
+ Object o362 = new Object();
+ Object o363 = new Object();
+ Object o364 = new Object();
+ Object o365 = new Object();
+ Object o366 = new Object();
+ Object o367 = new Object();
+ Object o368 = new Object();
+ Object o369 = new Object();
+ Object o370 = new Object();
+ Object o371 = new Object();
+ Object o372 = new Object();
+ Object o373 = new Object();
+ Object o374 = new Object();
+ Object o375 = new Object();
+ Object o376 = new Object();
+ Object o377 = new Object();
+ Object o378 = new Object();
+ Object o379 = new Object();
+ Object o380 = new Object();
+ Object o381 = new Object();
+ Object o382 = new Object();
+ Object o383 = new Object();
+ Object o384 = new Object();
+ Object o385 = new Object();
+ Object o386 = new Object();
+ Object o387 = new Object();
+ Object o388 = new Object();
+ Object o389 = new Object();
+ Object o390 = new Object();
+ Object o391 = new Object();
+ Object o392 = new Object();
+ Object o393 = new Object();
+ Object o394 = new Object();
+ Object o395 = new Object();
+ Object o396 = new Object();
+ Object o397 = new Object();
+ Object o398 = new Object();
+ Object o399 = new Object();
+ Object o400 = new Object();
+ Object o401 = new Object();
+ Object o402 = new Object();
+ Object o403 = new Object();
+ Object o404 = new Object();
+ Object o405 = new Object();
+ Object o406 = new Object();
+ Object o407 = new Object();
+ Object o408 = new Object();
+ Object o409 = new Object();
+ Object o410 = new Object();
+ Object o411 = new Object();
+ Object o412 = new Object();
+ Object o413 = new Object();
+ Object o414 = new Object();
+ Object o415 = new Object();
+ Object o416 = new Object();
+ Object o417 = new Object();
+ Object o418 = new Object();
+ Object o419 = new Object();
+ Object o420 = new Object();
+ Object o421 = new Object();
+ Object o422 = new Object();
+ Object o423 = new Object();
+ Object o424 = new Object();
+ Object o425 = new Object();
+ Object o426 = new Object();
+ Object o427 = new Object();
+ Object o428 = new Object();
+ Object o429 = new Object();
+ Object o430 = new Object();
+ Object o431 = new Object();
+ Object o432 = new Object();
+ Object o433 = new Object();
+ Object o434 = new Object();
+ Object o435 = new Object();
+ Object o436 = new Object();
+ Object o437 = new Object();
+ Object o438 = new Object();
+ Object o439 = new Object();
+ Object o440 = new Object();
+ Object o441 = new Object();
+ Object o442 = new Object();
+ Object o460 = new Object();
+ Object o461 = new Object();
+ Object o462 = new Object();
+ Object o463 = new Object();
+ Object o464 = new Object();
+ Object o465 = new Object();
+ Object o466 = new Object();
+ Object o467 = new Object();
+ Object o468 = new Object();
+ Object o469 = new Object();
+ Object o470 = new Object();
+ Object o471 = new Object();
+ Object o472 = new Object();
+ Object o473 = new Object();
+ Object o474 = new Object();
+ Object o475 = new Object();
+ Object o476 = new Object();
+ Object o477 = new Object();
+ Object o478 = new Object();
+ Object o479 = new Object();
+ Object o480 = new Object();
+ Object o481 = new Object();
+ Object o482 = new Object();
+ Object o483 = new Object();
+ Object o484 = new Object();
+ Object o485 = new Object();
+ Object o486 = new Object();
+ Object o487 = new Object();
+ Object o488 = new Object();
+ Object o489 = new Object();
+ Object o490 = new Object();
+ Object o491 = new Object();
+ Object o492 = new Object();
+ Object o493 = new Object();
+ Object o494 = new Object();
+ Object o495 = new Object();
+ Object o496 = new Object();
+ Object o497 = new Object();
+ Object o498 = new Object();
+ Object o499 = new Object();
+ Object o500 = new Object();
+ Object o501 = new Object();
+ Object o502 = new Object();
+ Object o503 = new Object();
+ Object o504 = new Object();
+ Object o505 = new Object();
+ Object o506 = new Object();
+ Object o507 = new Object();
+ Object o508 = new Object();
+ Object o509 = new Object();
+ Object o510 = new Object();
+ Object o511 = new Object();
+ Object o512 = new Object();
+ Object o513 = new Object();
+ Object o514 = new Object();
+ Object o515 = new Object();
+ Object o516 = new Object();
+ Object o517 = new Object();
+ Object o518 = new Object();
+ Object o519 = new Object();
+ Object o520 = new Object();
+ Object o521 = new Object();
+ Object o522 = new Object();
+ Object o523 = new Object();
+ Object o556 = new Object();
+ Object o557 = new Object();
+ Object o558 = new Object();
+ Object o559 = new Object();
+ Object o560 = new Object();
+ Object o561 = new Object();
+ Object o562 = new Object();
+ Object o563 = new Object();
+ Object o564 = new Object();
+ Object o565 = new Object();
+ Object o566 = new Object();
+ Object o567 = new Object();
+ Object o568 = new Object();
+ Object o569 = new Object();
+ Object o570 = new Object();
+ Object o571 = new Object();
+ Object o572 = new Object();
+ Object o573 = new Object();
+ Object o574 = new Object();
+ Object o575 = new Object();
+ Object o576 = new Object();
+ Object o577 = new Object();
+ Object o578 = new Object();
+ Object o579 = new Object();
+ Object o580 = new Object();
+ Object o581 = new Object();
+ Object o582 = new Object();
+ Object o583 = new Object();
+ Object o584 = new Object();
+ Object o585 = new Object();
+ Object o586 = new Object();
+ Object o587 = new Object();
+ Object o588 = new Object();
+ Object o589 = new Object();
+ Object o590 = new Object();
+ Object o591 = new Object();
+ Object o592 = new Object();
+ Object o593 = new Object();
+ Object o594 = new Object();
+ Object o595 = new Object();
+ Object o596 = new Object();
+ Object o597 = new Object();
+ Object o598 = new Object();
+ Object o599 = new Object();
+ Object o600 = new Object();
+ Object o601 = new Object();
+ Object o602 = new Object();
+ Object o603 = new Object();
+ Object o604 = new Object();
+ Object o605 = new Object();
+ Object o606 = new Object();
+ Object o607 = new Object();
+ Object o608 = new Object();
+ Object o609 = new Object();
+ Object o610 = new Object();
+ Object o611 = new Object();
+ Object o612 = new Object();
+ Object o613 = new Object();
+ Object o614 = new Object();
+ Object o615 = new Object();
+ Object o616 = new Object();
+ Object o617 = new Object();
+ Object o618 = new Object();
+ Object o619 = new Object();
+ Object o620 = new Object();
+ Object o621 = new Object();
+ Object o622 = new Object();
+ Object o623 = new Object();
+ Object o624 = new Object();
+ Object o625 = new Object();
+ Object o626 = new Object();
+ Object o627 = new Object();
+ Object o628 = new Object();
+ Object o629 = new Object();
+ Object o630 = new Object();
+ Object o631 = new Object();
+ Object o632 = new Object();
+ Object o633 = new Object();
+ Object o634 = new Object();
+ Object o635 = new Object();
+ Object o636 = new Object();
+ Object o637 = new Object();
+ Object o638 = new Object();
+ Object o639 = new Object();
+ Object o640 = new Object();
+ Object o641 = new Object();
+ Object o642 = new Object();
+ Object o643 = new Object();
+ Object o644 = new Object();
+ Object o645 = new Object();
+ Object o646 = new Object();
+ Object o647 = new Object();
+ Object o648 = new Object();
+ Object o649 = new Object();
+ Object o650 = new Object();
+ Object o651 = new Object();
+ Object o652 = new Object();
+ Object o653 = new Object();
+ Object o654 = new Object();
+ Object o655 = new Object();
+ Object o656 = new Object();
+ Object o657 = new Object();
+ Object o658 = new Object();
+ Object o659 = new Object();
+ Object o660 = new Object();
+ Object o661 = new Object();
+ Object o662 = new Object();
+ Object o663 = new Object();
+ Object o664 = new Object();
+ Object o665 = new Object();
+ Object o666 = new Object();
+ Object o667 = new Object();
+ Object o668 = new Object();
+ Object o669 = new Object();
+ Object o670 = new Object();
+ Object o671 = new Object();
+ Object o672 = new Object();
+ Object o673 = new Object();
+ Object o674 = new Object();
+ Object o675 = new Object();
+ Object o676 = new Object();
+ Object o677 = new Object();
+ Object o678 = new Object();
+ Object o679 = new Object();
+ Object o680 = new Object();
+ Object o681 = new Object();
+ Object o682 = new Object();
+ Object o683 = new Object();
+ Object o684 = new Object();
+ Object o685 = new Object();
+ Object o686 = new Object();
+ Object o687 = new Object();
+ Object o688 = new Object();
+ Object o734 = new Object();
+ Object o735 = new Object();
+ Object o736 = new Object();
+ Object o737 = new Object();
+ Object o738 = new Object();
+ Object o739 = new Object();
+ Object o740 = new Object();
+ Object o741 = new Object();
+ Object o742 = new Object();
+ Object o743 = new Object();
+ Object o744 = new Object();
+ Object o745 = new Object();
+ Object o746 = new Object();
+ Object o747 = new Object();
+ Object o748 = new Object();
+ Object o749 = new Object();
+ Object o750 = new Object();
+ Object o751 = new Object();
+ Object o752 = new Object();
+ Object o753 = new Object();
+ Object o754 = new Object();
+ Object o755 = new Object();
+ Object o756 = new Object();
+ Object o757 = new Object();
+ Object o758 = new Object();
+ Object o759 = new Object();
+ Object o760 = new Object();
+ Object o761 = new Object();
+ Object o762 = new Object();
+ Object o763 = new Object();
+ Object o764 = new Object();
+ Object o765 = new Object();
+ Object o766 = new Object();
+ Object o767 = new Object();
+ Object o768 = new Object();
+ Object o769 = new Object();
+ Object o770 = new Object();
+ Object o771 = new Object();
+ Object o772 = new Object();
+ Object o773 = new Object();
+ Object o774 = new Object();
+ Object o775 = new Object();
+ Object o776 = new Object();
+ Object o777 = new Object();
+ Object o778 = new Object();
+ Object o779 = new Object();
+ Object o780 = new Object();
+ Object o781 = new Object();
+ Object o782 = new Object();
+ Object o783 = new Object();
+ Object o784 = new Object();
+ Object o785 = new Object();
+ Object o786 = new Object();
+ Object o787 = new Object();
+ Object o788 = new Object();
+ Object o789 = new Object();
+ Object o790 = new Object();
+ Object o791 = new Object();
+ Object o792 = new Object();
+ Object o793 = new Object();
+ Object o794 = new Object();
+ Object o795 = new Object();
+ Object o796 = new Object();
+ Object o797 = new Object();
+ Object o798 = new Object();
+ Object o799 = new Object();
+ Object o800 = new Object();
+ Object o801 = new Object();
+ Object o802 = new Object();
+ Object o803 = new Object();
+ Object o804 = new Object();
+ Object o805 = new Object();
+ Object o806 = new Object();
+ Object o807 = new Object();
+ Object o808 = new Object();
+ Object o809 = new Object();
+ Object o810 = new Object();
+ Object o811 = new Object();
+ Object o812 = new Object();
+ Object o813 = new Object();
+ Object o848 = new Object();
+ Object o849 = new Object();
+ Object o850 = new Object();
+ Object o851 = new Object();
+ Object o852 = new Object();
+ Object o853 = new Object();
+ Object o854 = new Object();
+ Object o855 = new Object();
+ Object o856 = new Object();
+ Object o857 = new Object();
+ Object o858 = new Object();
+ Object o859 = new Object();
+ Object o860 = new Object();
+ Object o861 = new Object();
+ Object o862 = new Object();
+ Object o863 = new Object();
+ Object o864 = new Object();
+ Object o865 = new Object();
+ Object o866 = new Object();
+ Object o867 = new Object();
+ Object o868 = new Object();
+ Object o869 = new Object();
+ Object o870 = new Object();
+ Object o871 = new Object();
+ Object o872 = new Object();
+ Object o873 = new Object();
+ Object o874 = new Object();
+ Object o875 = new Object();
+ Object o876 = new Object();
+ Object o877 = new Object();
+ Object o878 = new Object();
+ Object o879 = new Object();
+ Object o880 = new Object();
+ Object o881 = new Object();
+ Object o882 = new Object();
+ Object o883 = new Object();
+ Object o884 = new Object();
+ Object o885 = new Object();
+ Object o886 = new Object();
+ Object o887 = new Object();
+ Object o888 = new Object();
+ Object o889 = new Object();
+ Object o890 = new Object();
+ Object o891 = new Object();
+ Object o892 = new Object();
+ Object o893 = new Object();
+ Object o894 = new Object();
+ Object o895 = new Object();
+ Object o896 = new Object();
+ Object o897 = new Object();
+ Object o898 = new Object();
+ Object o899 = new Object();
+ Object o900 = new Object();
+ Object o901 = new Object();
+ Object o902 = new Object();
+ Object o903 = new Object();
+ Object o904 = new Object();
+ Object o905 = new Object();
+ Object o906 = new Object();
+ Object o907 = new Object();
+ Object o908 = new Object();
+ Object o909 = new Object();
+ Object o910 = new Object();
+ Object o911 = new Object();
+ Object o912 = new Object();
+ Object o913 = new Object();
+ Object o914 = new Object();
+ Object o915 = new Object();
+ Object o916 = new Object();
+ Object o917 = new Object();
+ Object o918 = new Object();
+ Object o919 = new Object();
+ Object o920 = new Object();
+ Object o921 = new Object();
+ Object o922 = new Object();
+ Object o923 = new Object();
+ Object o924 = new Object();
+ Object o925 = new Object();
+ Object o926 = new Object();
+ Object o927 = new Object();
+ Object o928 = new Object();
+ Object o929 = new Object();
+ Object o930 = new Object();
+ Object o931 = new Object();
+ Object o932 = new Object();
+ Object o933 = new Object();
+ Object o934 = new Object();
+ Object o935 = new Object();
+ Object o936 = new Object();
+ Object o937 = new Object();
+ Object o938 = new Object();
+ Object o939 = new Object();
+ Object o940 = new Object();
+ Object o941 = new Object();
+ Object o942 = new Object();
+ Object o943 = new Object();
+ Object o944 = new Object();
+ Object o945 = new Object();
+ Object o946 = new Object();
+ Object o947 = new Object();
+ Object o948 = new Object();
+ Object o949 = new Object();
+ Object o950 = new Object();
+ Object o951 = new Object();
+ Object o952 = new Object();
+ Object o953 = new Object();
+ Object o954 = new Object();
+ Object o955 = new Object();
+ Object o956 = new Object();
+ Object o957 = new Object();
+ Object o958 = new Object();
+ Object o959 = new Object();
+ Object o960 = new Object();
+ Object o961 = new Object();
+ Object o962 = new Object();
+ Object o963 = new Object();
+ Object o964 = new Object();
+ Object o965 = new Object();
+ Object o966 = new Object();
+ Object o967 = new Object();
+ Object o968 = new Object();
+ Object o969 = new Object();
+ Object o970 = new Object();
+ Object o971 = new Object();
+ Object o972 = new Object();
+ Object o973 = new Object();
+ Object o974 = new Object();
+ Object o975 = new Object();
+ Object o976 = new Object();
+ Object o977 = new Object();
+ Object o978 = new Object();
+ Object o979 = new Object();
+ Object o980 = new Object();
+ Object o981 = new Object();
+ Object o982 = new Object();
+ Object o983 = new Object();
+ Object o984 = new Object();
+ Object o985 = new Object();
+ Object o986 = new Object();
+ Object o987 = new Object();
+ Object o988 = new Object();
+ Object o989 = new Object();
+ Object o990 = new Object();
+ Object o991 = new Object();
+ Object o992 = new Object();
+ Object o993 = new Object();
+ Object o994 = new Object();
+ Object o995 = new Object();
+ Object o996 = new Object();
+ Object o997 = new Object();
+ Object o998 = new Object();
+ Object o999 = new Object();
+ }
+
+ static class Deep0 {}
+ static class Deep1 extends Deep0 {}
+ static class Deep2 extends Deep1 {}
+ static class Deep3 extends Deep2 {}
+ static class Deep4 extends Deep3 {}
+ static class Deep5 extends Deep4 {}
+ static class Deep6 extends Deep5 {}
+ static class Deep7 extends Deep6 {}
+ static class Deep8 extends Deep7 {}
+ static class Deep9 extends Deep8 {}
+ static class Deep10 extends Deep9 {}
+ static class Deep11 extends Deep10 {}
+ static class Deep12 extends Deep11 {}
+ static class Deep13 extends Deep12 {}
+ static class Deep14 extends Deep13 {}
+ static class Deep15 extends Deep14 {}
+ static class Deep16 extends Deep15 {}
+ static class Deep17 extends Deep16 {}
+ static class Deep18 extends Deep17 {}
+ static class Deep19 extends Deep18 {}
+ static class Deep20 extends Deep19 {}
+ static class Deep21 extends Deep20 {}
+ static class Deep22 extends Deep21 {}
+ static class Deep23 extends Deep22 {}
+ static class Deep24 extends Deep23 {}
+ static class Deep25 extends Deep24 {}
+ static class Deep26 extends Deep25 {}
+ static class Deep27 extends Deep26 {}
+ static class Deep28 extends Deep27 {}
+ static class Deep29 extends Deep28 {}
+ static class Deep30 extends Deep29 {}
+ static class Deep31 extends Deep30 {}
+ static class Deep32 extends Deep31 {}
+ static class Deep33 extends Deep32 {}
+ static class Deep34 extends Deep33 {}
+ static class Deep35 extends Deep34 {}
+ static class Deep36 extends Deep35 {}
+ static class Deep37 extends Deep36 {}
+ static class Deep38 extends Deep37 {}
+ static class Deep39 extends Deep38 {}
+ static class Deep40 extends Deep39 {}
+ static class Deep41 extends Deep40 {}
+ static class Deep42 extends Deep41 {}
+ static class Deep43 extends Deep42 {}
+ static class Deep44 extends Deep43 {}
+ static class Deep45 extends Deep44 {}
+ static class Deep46 extends Deep45 {}
+ static class Deep47 extends Deep46 {}
+ static class Deep48 extends Deep47 {}
+ static class Deep49 extends Deep48 {}
+ static class Deep50 extends Deep49 {}
+ static class Deep51 extends Deep50 {}
+ static class Deep52 extends Deep51 {}
+ static class Deep53 extends Deep52 {}
+ static class Deep54 extends Deep53 {}
+ static class Deep55 extends Deep54 {}
+ static class Deep56 extends Deep55 {}
+ static class Deep57 extends Deep56 {}
+ static class Deep58 extends Deep57 {}
+ static class Deep59 extends Deep58 {}
+ static class Deep60 extends Deep59 {}
+ static class Deep61 extends Deep60 {}
+ static class Deep62 extends Deep61 {}
+ static class Deep63 extends Deep62 {}
+ static class Deep64 extends Deep63 {}
+ static class Deep65 extends Deep64 {}
+ static class Deep66 extends Deep65 {}
+ static class Deep67 extends Deep66 {}
+ static class Deep68 extends Deep67 {}
+ static class Deep69 extends Deep68 {}
+ static class Deep70 extends Deep69 {}
+ static class Deep71 extends Deep70 {}
+ static class Deep72 extends Deep71 {}
+ static class Deep73 extends Deep72 {}
+ static class Deep74 extends Deep73 {}
+ static class Deep75 extends Deep74 {}
+ static class Deep76 extends Deep75 {}
+ static class Deep77 extends Deep76 {}
+ static class Deep78 extends Deep77 {}
+ static class Deep79 extends Deep78 {}
+ static class Deep80 extends Deep79 {}
+ static class Deep81 extends Deep80 {}
+ static class Deep82 extends Deep81 {}
+ static class Deep83 extends Deep82 {}
+ static class Deep84 extends Deep83 {}
+ static class Deep85 extends Deep84 {}
+ static class Deep86 extends Deep85 {}
+ static class Deep87 extends Deep86 {}
+ static class Deep88 extends Deep87 {}
+ static class Deep89 extends Deep88 {}
+ static class Deep90 extends Deep89 {}
+ static class Deep91 extends Deep90 {}
+ static class Deep92 extends Deep91 {}
+ static class Deep93 extends Deep92 {}
+ static class Deep94 extends Deep93 {}
+ static class Deep95 extends Deep94 {}
+ static class Deep96 extends Deep95 {}
+ static class Deep97 extends Deep96 {}
+ static class Deep98 extends Deep97 {}
+ static class Deep99 extends Deep98 {}
+ static class Deep100 extends Deep99 {}
+
+ static class DeepCloneable extends Deep100 implements Cloneable {
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ }
+
+ public void time_Object_clone(int reps) {
+ try {
+ CloneableObject o = new CloneableObject();
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ } catch (Exception e) {
+ throw new AssertionError(e.getMessage());
+ }
+ }
+
+ public void time_Object_manyFieldClone(int reps) {
+ try {
+ CloneableManyFieldObject o = new CloneableManyFieldObject();
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ } catch (Exception e) {
+ throw new AssertionError(e.getMessage());
+ }
+ }
+
+ public void time_Object_deepClone(int reps) {
+ try {
+ DeepCloneable o = new DeepCloneable();
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ } catch (Exception e) {
+ throw new AssertionError(e.getMessage());
+ }
+ }
+
+ public void time_Array_clone(int reps) {
+ int[] o = new int[32];
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ }
+
+ public void time_ObjectArray_smallClone(int reps) {
+ Object[] o = new Object[32];
+ for (int i = 0; i < o.length / 2; ++i) {
+ o[i] = new Object();
+ }
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ }
+
+ public void time_ObjectArray_largeClone(int reps) {
+ Object[] o = new Object[2048];
+ for (int i = 0; i < o.length / 2; ++i) {
+ o[i] = new Object();
+ }
+ for (int rep = 0; rep < reps; ++rep) {
+ o.clone();
+ }
+ }
+}
diff --git a/benchmarks/DeepArrayOpsBenchmark.java b/benchmarks/DeepArrayOpsBenchmark.java
new file mode 100644
index 0000000..c671da6
--- /dev/null
+++ b/benchmarks/DeepArrayOpsBenchmark.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Benchmark;
+import com.google.caliper.Param;
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+
+public class DeepArrayOpsBenchmark {
+ @Param({"0001", "0004", "0016", "0256", "2048"}) int arrayLength;
+
+ private Object[] array;
+ private Object[] array2;
+
+ @BeforeExperiment public void setUp() throws Exception {
+ array = new Object[arrayLength * 14];
+ array2 = new Object[arrayLength * 14];
+ for (int i = 0; i < arrayLength; i += 14) {
+ array[i] = new IntWrapper(i);
+ array2[i] = new IntWrapper(i);
+
+ array[i + 1] = new16ElementObjectarray();
+ array2[i + 1] = new16ElementObjectarray();
+
+ array[i + 2] = new boolean[16];
+ array2[i + 2] = new boolean[16];
+
+ array[i + 3] = new byte[16];
+ array2[i + 3] = new byte[16];
+
+ array[i + 4] = new char[16];
+ array2[i + 4] = new char[16];
+
+ array[i + 5] = new short[16];
+ array2[i + 5] = new short[16];
+
+ array[i + 6] = new float[16];
+ array2[i + 6] = new float[16];
+
+ array[i + 7] = new long[16];
+ array2[i + 7] = new long[16];
+
+ array[i + 8] = new int[16];
+ array2[i + 8] = new int[16];
+
+ array[i + 9] = new double[16];
+ array2[i + 9] = new double[16];
+
+ // Subarray types are concrete objects.
+ array[i + 10] = new16ElementArray(String.class, String.class);
+ array2[i + 10] = new16ElementArray(String.class, String.class);
+
+ array[i + 11] = new16ElementArray(Integer.class, Integer.class);
+ array2[i + 11] = new16ElementArray(Integer.class, Integer.class);
+
+ // Subarray types is an interface.
+ array[i + 12] = new16ElementArray(CharSequence.class, String.class);
+ array2[i + 12] = new16ElementArray(CharSequence.class, String.class);
+
+ array[i + 13] = null;
+ array2[i + 13] = null;
+ }
+ }
+
+ @Benchmark public void deepHashCode(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ Arrays.deepHashCode(array);
+ }
+ }
+
+ @Benchmark public void deepEquals(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ Arrays.deepEquals(array, array2);
+ }
+ }
+
+ private static final Object[] new16ElementObjectarray() {
+ Object[] array = new Object[16];
+ for (int i = 0; i < 16; ++i) {
+ array[i] = new IntWrapper(i);
+ }
+
+ return array;
+ }
+
+ @SuppressWarnings("unchecked")
+ private static final <T, V> T[] new16ElementArray(Class<T> arrayType, Class<V> type)
+ throws Exception {
+ T[] array = (T []) Array.newInstance(type, 16);
+ if (!arrayType.isAssignableFrom(type)) {
+ throw new IllegalArgumentException(arrayType + " is not assignable from " + type);
+ }
+
+ Constructor<V> constructor = type.getDeclaredConstructor(String.class);
+ for (int i = 0; i < 16; ++i) {
+ array[i] = (T) constructor.newInstance(String.valueOf(i + 1000));
+ }
+
+ return array;
+ }
+
+ /**
+ * A class that provides very basic equals() and hashCode() operations
+ * and doesn't resort to memoization tricks like {@link java.lang.Integer}.
+ *
+ * Useful for providing equal objects that aren't the same (a.equals(b) but
+ * a != b).
+ */
+ public static final class IntWrapper {
+ private final int wrapped;
+
+ public IntWrapper(int wrap) {
+ wrapped = wrap;
+ }
+
+ @Override
+ public int hashCode() {
+ return wrapped;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof IntWrapper)) {
+ return false;
+ }
+
+ return ((IntWrapper) o).wrapped == this.wrapped;
+ }
+ }
+}
diff --git a/benchmarks/FieldAccessBenchmark.java b/benchmarks/FieldAccessBenchmark.java
new file mode 100644
index 0000000..c2391d6
--- /dev/null
+++ b/benchmarks/FieldAccessBenchmark.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * What does field access cost?
+ */
+public class FieldAccessBenchmark {
+ private static class Inner {
+ public int publicInnerIntVal;
+ protected int protectedInnerIntVal;
+ private int privateInnerIntVal;
+ int packageInnerIntVal;
+ }
+ int intVal = 42;
+ final int finalIntVal = 42;
+ static int staticIntVal = 42;
+ static final int staticFinalIntVal = 42;
+ public int timeField(int reps) {
+ int result = 0;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = intVal;
+ }
+ return result;
+ }
+ public int timeFieldFinal(int reps) {
+ int result = 0;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = finalIntVal;
+ }
+ return result;
+ }
+ public int timeFieldStatic(int reps) {
+ int result = 0;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = staticIntVal;
+ }
+ return result;
+ }
+ public int timeFieldStaticFinal(int reps) {
+ int result = 0;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = staticFinalIntVal;
+ }
+ return result;
+ }
+ public int timeFieldCached(int reps) {
+ int result = 0;
+ int cachedIntVal = this.intVal;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = cachedIntVal;
+ }
+ return result;
+ }
+ public int timeFieldPrivateInnerClassPublicField(int reps) {
+ int result = 0;
+ Inner inner = new Inner();
+ for (int rep = 0; rep < reps; ++rep) {
+ result = inner.publicInnerIntVal;
+ }
+ return result;
+ }
+ public int timeFieldPrivateInnerClassProtectedField(int reps) {
+ int result = 0;
+ Inner inner = new Inner();
+ for (int rep = 0; rep < reps; ++rep) {
+ result = inner.protectedInnerIntVal;
+ }
+ return result;
+ }
+ public int timeFieldPrivateInnerClassPrivateField(int reps) {
+ int result = 0;
+ Inner inner = new Inner();
+ for (int rep = 0; rep < reps; ++rep) {
+ result = inner.privateInnerIntVal;
+ }
+ return result;
+ }
+ public int timeFieldPrivateInnerClassPackageField(int reps) {
+ int result = 0;
+ Inner inner = new Inner();
+ for (int rep = 0; rep < reps; ++rep) {
+ result = inner.packageInnerIntVal;
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/Foo.java b/benchmarks/Foo.java
new file mode 100644
index 0000000..d288dd6
--- /dev/null
+++ b/benchmarks/Foo.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * A trivial class used by several benchmarks.
+ */
+public class Foo {
+ int mSplat;
+}
diff --git a/benchmarks/GetSystemPropertyBenchmark.java b/benchmarks/GetSystemPropertyBenchmark.java
new file mode 100644
index 0000000..3a93285
--- /dev/null
+++ b/benchmarks/GetSystemPropertyBenchmark.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.security.AccessController;
+
+import sun.security.action.GetPropertyAction;
+
+/**
+ * Compares performance of accessing system properties via
+ * legacy security code
+ * {@code AccessController.doPrivileged(new GetPropertyAction(key[, default]))}
+ * vs. direct invocation of {@code System.getProperty(key[, default])}.
+ *
+ * As of 2018-07, libcore carries some patches to perform such short-circuiting,
+ * so it's interesting to know how much better it performs.
+ */
+public class GetSystemPropertyBenchmark {
+
+ public void timeSystem_getProperty_default(int reps) {
+ for (int i = 0; i < reps; i++) {
+ System.getProperty("user.language", "en");
+ }
+ }
+
+ public void timeSystem_getProperty(int reps) {
+ for (int i = 0; i < reps; i++) {
+ System.getProperty("user.region");
+ }
+ }
+
+ public void timeAccessController_getPropertyAction(int reps) {
+ for (int i = 0; i < reps; i++) {
+ AccessController.doPrivileged(
+ new GetPropertyAction("user.language", "en"));
+ }
+ }
+
+ public void timeAccessController_getPropertyAction_default(int reps) {
+ for (int i = 0; i < reps; i++) {
+ AccessController.doPrivileged(
+ new GetPropertyAction("user.region"));
+ }
+ }
+
+}
diff --git a/benchmarks/HashedCollectionsBenchmark.java b/benchmarks/HashedCollectionsBenchmark.java
new file mode 100644
index 0000000..f2ecd1d
--- /dev/null
+++ b/benchmarks/HashedCollectionsBenchmark.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * How do the various hash maps compare?
+ */
+public class HashedCollectionsBenchmark {
+ public void timeHashMapGet(int reps) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put("hello", "world");
+ for (int i = 0; i < reps; ++i) {
+ map.get("hello");
+ }
+ }
+ public void timeHashMapGet_Synchronized(int reps) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ synchronized (map) {
+ map.put("hello", "world");
+ }
+ for (int i = 0; i < reps; ++i) {
+ synchronized (map) {
+ map.get("hello");
+ }
+ }
+ }
+ public void timeHashtableGet(int reps) {
+ Hashtable<String, String> map = new Hashtable<String, String>();
+ map.put("hello", "world");
+ for (int i = 0; i < reps; ++i) {
+ map.get("hello");
+ }
+ }
+ public void timeLinkedHashMapGet(int reps) {
+ LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+ map.put("hello", "world");
+ for (int i = 0; i < reps; ++i) {
+ map.get("hello");
+ }
+ }
+ public void timeConcurrentHashMapGet(int reps) {
+ ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>();
+ map.put("hello", "world");
+ for (int i = 0; i < reps; ++i) {
+ map.get("hello");
+ }
+ }
+}
diff --git a/benchmarks/ImtConflictBenchmark.java b/benchmarks/ImtConflictBenchmark.java
new file mode 100644
index 0000000..faff03d
--- /dev/null
+++ b/benchmarks/ImtConflictBenchmark.java
@@ -0,0 +1,1706 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+import com.google.caliper.BeforeExperiment;
+
+/**
+ * This file is script-generated by ImtConflictBenchmarkGen.py.
+ * It measures the performance impact of conflicts in interface method tables.
+ * Run `python ImtConflictBenchmarkGen.py > ImtConflictBenchmark.java` to regenerate.
+ *
+ * Each interface has 64 methods, which is the current size of an IMT. C0 implements
+ * one interface, C1 implements two, C2 implements three, and so on. The intent
+ * is that C0 has no conflicts in its IMT, C1 has depth-2 conflicts in
+ * its IMT, C2 has depth-3 conflicts, etc. This is currently guaranteed by
+ * the fact that we hash interface methods by taking their method index modulo 64.
+ * (Note that a "conflict depth" of 1 means no conflict at all.)
+ */
+public class ImtConflictBenchmark {
+ @BeforeExperiment
+ public void setup() {
+ C0 c0 = new C0();
+ callF0(c0);
+ C1 c1 = new C1();
+ callF0(c1);
+ callF43(c1);
+ C2 c2 = new C2();
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ C3 c3 = new C3();
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ C4 c4 = new C4();
+ callF0(c4);
+ callF43(c4);
+ callF86(c4);
+ callF129(c4);
+ callF172(c4);
+ C5 c5 = new C5();
+ callF0(c5);
+ callF43(c5);
+ callF86(c5);
+ callF129(c5);
+ callF172(c5);
+ callF215(c5);
+ C6 c6 = new C6();
+ callF0(c6);
+ callF43(c6);
+ callF86(c6);
+ callF129(c6);
+ callF172(c6);
+ callF215(c6);
+ callF258(c6);
+ C7 c7 = new C7();
+ callF0(c7);
+ callF43(c7);
+ callF86(c7);
+ callF129(c7);
+ callF172(c7);
+ callF215(c7);
+ callF258(c7);
+ callF301(c7);
+ C8 c8 = new C8();
+ callF0(c8);
+ callF43(c8);
+ callF86(c8);
+ callF129(c8);
+ callF172(c8);
+ callF215(c8);
+ callF258(c8);
+ callF301(c8);
+ callF344(c8);
+ C9 c9 = new C9();
+ callF0(c9);
+ callF43(c9);
+ callF86(c9);
+ callF129(c9);
+ callF172(c9);
+ callF215(c9);
+ callF258(c9);
+ callF301(c9);
+ callF344(c9);
+ callF387(c9);
+ C10 c10 = new C10();
+ callF0(c10);
+ callF43(c10);
+ callF86(c10);
+ callF129(c10);
+ callF172(c10);
+ callF215(c10);
+ callF258(c10);
+ callF301(c10);
+ callF344(c10);
+ callF387(c10);
+ callF430(c10);
+ C11 c11 = new C11();
+ callF0(c11);
+ callF43(c11);
+ callF86(c11);
+ callF129(c11);
+ callF172(c11);
+ callF215(c11);
+ callF258(c11);
+ callF301(c11);
+ callF344(c11);
+ callF387(c11);
+ callF430(c11);
+ callF473(c11);
+ C12 c12 = new C12();
+ callF0(c12);
+ callF43(c12);
+ callF86(c12);
+ callF129(c12);
+ callF172(c12);
+ callF215(c12);
+ callF258(c12);
+ callF301(c12);
+ callF344(c12);
+ callF387(c12);
+ callF430(c12);
+ callF473(c12);
+ callF516(c12);
+ C13 c13 = new C13();
+ callF0(c13);
+ callF43(c13);
+ callF86(c13);
+ callF129(c13);
+ callF172(c13);
+ callF215(c13);
+ callF258(c13);
+ callF301(c13);
+ callF344(c13);
+ callF387(c13);
+ callF430(c13);
+ callF473(c13);
+ callF516(c13);
+ callF559(c13);
+ C14 c14 = new C14();
+ callF0(c14);
+ callF43(c14);
+ callF86(c14);
+ callF129(c14);
+ callF172(c14);
+ callF215(c14);
+ callF258(c14);
+ callF301(c14);
+ callF344(c14);
+ callF387(c14);
+ callF430(c14);
+ callF473(c14);
+ callF516(c14);
+ callF559(c14);
+ callF602(c14);
+ C15 c15 = new C15();
+ callF0(c15);
+ callF43(c15);
+ callF86(c15);
+ callF129(c15);
+ callF172(c15);
+ callF215(c15);
+ callF258(c15);
+ callF301(c15);
+ callF344(c15);
+ callF387(c15);
+ callF430(c15);
+ callF473(c15);
+ callF516(c15);
+ callF559(c15);
+ callF602(c15);
+ callF645(c15);
+ C16 c16 = new C16();
+ callF0(c16);
+ callF43(c16);
+ callF86(c16);
+ callF129(c16);
+ callF172(c16);
+ callF215(c16);
+ callF258(c16);
+ callF301(c16);
+ callF344(c16);
+ callF387(c16);
+ callF430(c16);
+ callF473(c16);
+ callF516(c16);
+ callF559(c16);
+ callF602(c16);
+ callF645(c16);
+ callF688(c16);
+ C17 c17 = new C17();
+ callF0(c17);
+ callF43(c17);
+ callF86(c17);
+ callF129(c17);
+ callF172(c17);
+ callF215(c17);
+ callF258(c17);
+ callF301(c17);
+ callF344(c17);
+ callF387(c17);
+ callF430(c17);
+ callF473(c17);
+ callF516(c17);
+ callF559(c17);
+ callF602(c17);
+ callF645(c17);
+ callF688(c17);
+ callF731(c17);
+ C18 c18 = new C18();
+ callF0(c18);
+ callF43(c18);
+ callF86(c18);
+ callF129(c18);
+ callF172(c18);
+ callF215(c18);
+ callF258(c18);
+ callF301(c18);
+ callF344(c18);
+ callF387(c18);
+ callF430(c18);
+ callF473(c18);
+ callF516(c18);
+ callF559(c18);
+ callF602(c18);
+ callF645(c18);
+ callF688(c18);
+ callF731(c18);
+ callF774(c18);
+ C19 c19 = new C19();
+ callF0(c19);
+ callF43(c19);
+ callF86(c19);
+ callF129(c19);
+ callF172(c19);
+ callF215(c19);
+ callF258(c19);
+ callF301(c19);
+ callF344(c19);
+ callF387(c19);
+ callF430(c19);
+ callF473(c19);
+ callF516(c19);
+ callF559(c19);
+ callF602(c19);
+ callF645(c19);
+ callF688(c19);
+ callF731(c19);
+ callF774(c19);
+ callF817(c19);
+ }
+ public void timeConflictDepth01(int nreps) {
+ C0 c0 = new C0();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ callF0(c0);
+ }
+ }
+ public void timeConflictDepth02(int nreps) {
+ C1 c1 = new C1();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ callF0(c1);
+ callF43(c1);
+ }
+ }
+ public void timeConflictDepth03(int nreps) {
+ C2 c2 = new C2();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ callF86(c2);
+ callF0(c2);
+ callF43(c2);
+ }
+ }
+ public void timeConflictDepth04(int nreps) {
+ C3 c3 = new C3();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ callF0(c3);
+ callF43(c3);
+ callF86(c3);
+ callF129(c3);
+ }
+ }
+ public void timeConflictDepth05(int nreps) {
+ C4 c4 = new C4();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c4);
+ callF43(c4);
+ callF86(c4);
+ callF129(c4);
+ callF172(c4);
+ callF0(c4);
+ callF43(c4);
+ callF86(c4);
+ callF129(c4);
+ callF172(c4);
+ callF0(c4);
+ callF43(c4);
+ callF86(c4);
+ callF129(c4);
+ callF172(c4);
+ callF0(c4);
+ callF43(c4);
+ callF86(c4);
+ callF129(c4);
+ callF172(c4);
+ }
+ }
+ public void timeConflictDepth06(int nreps) {
+ C5 c5 = new C5();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c5);
+ callF43(c5);
+ callF86(c5);
+ callF129(c5);
+ callF172(c5);
+ callF215(c5);
+ callF0(c5);
+ callF43(c5);
+ callF86(c5);
+ callF129(c5);
+ callF172(c5);
+ callF215(c5);
+ callF0(c5);
+ callF43(c5);
+ callF86(c5);
+ callF129(c5);
+ callF172(c5);
+ callF215(c5);
+ callF0(c5);
+ callF43(c5);
+ }
+ }
+ public void timeConflictDepth07(int nreps) {
+ C6 c6 = new C6();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c6);
+ callF43(c6);
+ callF86(c6);
+ callF129(c6);
+ callF172(c6);
+ callF215(c6);
+ callF258(c6);
+ callF0(c6);
+ callF43(c6);
+ callF86(c6);
+ callF129(c6);
+ callF172(c6);
+ callF215(c6);
+ callF258(c6);
+ callF0(c6);
+ callF43(c6);
+ callF86(c6);
+ callF129(c6);
+ callF172(c6);
+ callF215(c6);
+ }
+ }
+ public void timeConflictDepth08(int nreps) {
+ C7 c7 = new C7();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c7);
+ callF43(c7);
+ callF86(c7);
+ callF129(c7);
+ callF172(c7);
+ callF215(c7);
+ callF258(c7);
+ callF301(c7);
+ callF0(c7);
+ callF43(c7);
+ callF86(c7);
+ callF129(c7);
+ callF172(c7);
+ callF215(c7);
+ callF258(c7);
+ callF301(c7);
+ callF0(c7);
+ callF43(c7);
+ callF86(c7);
+ callF129(c7);
+ }
+ }
+ public void timeConflictDepth09(int nreps) {
+ C8 c8 = new C8();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c8);
+ callF43(c8);
+ callF86(c8);
+ callF129(c8);
+ callF172(c8);
+ callF215(c8);
+ callF258(c8);
+ callF301(c8);
+ callF344(c8);
+ callF0(c8);
+ callF43(c8);
+ callF86(c8);
+ callF129(c8);
+ callF172(c8);
+ callF215(c8);
+ callF258(c8);
+ callF301(c8);
+ callF344(c8);
+ callF0(c8);
+ callF43(c8);
+ }
+ }
+ public void timeConflictDepth10(int nreps) {
+ C9 c9 = new C9();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c9);
+ callF43(c9);
+ callF86(c9);
+ callF129(c9);
+ callF172(c9);
+ callF215(c9);
+ callF258(c9);
+ callF301(c9);
+ callF344(c9);
+ callF387(c9);
+ callF0(c9);
+ callF43(c9);
+ callF86(c9);
+ callF129(c9);
+ callF172(c9);
+ callF215(c9);
+ callF258(c9);
+ callF301(c9);
+ callF344(c9);
+ callF387(c9);
+ }
+ }
+ public void timeConflictDepth11(int nreps) {
+ C10 c10 = new C10();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c10);
+ callF43(c10);
+ callF86(c10);
+ callF129(c10);
+ callF172(c10);
+ callF215(c10);
+ callF258(c10);
+ callF301(c10);
+ callF344(c10);
+ callF387(c10);
+ callF430(c10);
+ callF0(c10);
+ callF43(c10);
+ callF86(c10);
+ callF129(c10);
+ callF172(c10);
+ callF215(c10);
+ callF258(c10);
+ callF301(c10);
+ callF344(c10);
+ }
+ }
+ public void timeConflictDepth12(int nreps) {
+ C11 c11 = new C11();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c11);
+ callF43(c11);
+ callF86(c11);
+ callF129(c11);
+ callF172(c11);
+ callF215(c11);
+ callF258(c11);
+ callF301(c11);
+ callF344(c11);
+ callF387(c11);
+ callF430(c11);
+ callF473(c11);
+ callF0(c11);
+ callF43(c11);
+ callF86(c11);
+ callF129(c11);
+ callF172(c11);
+ callF215(c11);
+ callF258(c11);
+ callF301(c11);
+ }
+ }
+ public void timeConflictDepth13(int nreps) {
+ C12 c12 = new C12();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c12);
+ callF43(c12);
+ callF86(c12);
+ callF129(c12);
+ callF172(c12);
+ callF215(c12);
+ callF258(c12);
+ callF301(c12);
+ callF344(c12);
+ callF387(c12);
+ callF430(c12);
+ callF473(c12);
+ callF516(c12);
+ callF0(c12);
+ callF43(c12);
+ callF86(c12);
+ callF129(c12);
+ callF172(c12);
+ callF215(c12);
+ callF258(c12);
+ }
+ }
+ public void timeConflictDepth14(int nreps) {
+ C13 c13 = new C13();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c13);
+ callF43(c13);
+ callF86(c13);
+ callF129(c13);
+ callF172(c13);
+ callF215(c13);
+ callF258(c13);
+ callF301(c13);
+ callF344(c13);
+ callF387(c13);
+ callF430(c13);
+ callF473(c13);
+ callF516(c13);
+ callF559(c13);
+ callF0(c13);
+ callF43(c13);
+ callF86(c13);
+ callF129(c13);
+ callF172(c13);
+ callF215(c13);
+ }
+ }
+ public void timeConflictDepth15(int nreps) {
+ C14 c14 = new C14();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c14);
+ callF43(c14);
+ callF86(c14);
+ callF129(c14);
+ callF172(c14);
+ callF215(c14);
+ callF258(c14);
+ callF301(c14);
+ callF344(c14);
+ callF387(c14);
+ callF430(c14);
+ callF473(c14);
+ callF516(c14);
+ callF559(c14);
+ callF602(c14);
+ callF0(c14);
+ callF43(c14);
+ callF86(c14);
+ callF129(c14);
+ callF172(c14);
+ }
+ }
+ public void timeConflictDepth16(int nreps) {
+ C15 c15 = new C15();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c15);
+ callF43(c15);
+ callF86(c15);
+ callF129(c15);
+ callF172(c15);
+ callF215(c15);
+ callF258(c15);
+ callF301(c15);
+ callF344(c15);
+ callF387(c15);
+ callF430(c15);
+ callF473(c15);
+ callF516(c15);
+ callF559(c15);
+ callF602(c15);
+ callF645(c15);
+ callF0(c15);
+ callF43(c15);
+ callF86(c15);
+ callF129(c15);
+ }
+ }
+ public void timeConflictDepth17(int nreps) {
+ C16 c16 = new C16();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c16);
+ callF43(c16);
+ callF86(c16);
+ callF129(c16);
+ callF172(c16);
+ callF215(c16);
+ callF258(c16);
+ callF301(c16);
+ callF344(c16);
+ callF387(c16);
+ callF430(c16);
+ callF473(c16);
+ callF516(c16);
+ callF559(c16);
+ callF602(c16);
+ callF645(c16);
+ callF688(c16);
+ callF0(c16);
+ callF43(c16);
+ callF86(c16);
+ }
+ }
+ public void timeConflictDepth18(int nreps) {
+ C17 c17 = new C17();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c17);
+ callF43(c17);
+ callF86(c17);
+ callF129(c17);
+ callF172(c17);
+ callF215(c17);
+ callF258(c17);
+ callF301(c17);
+ callF344(c17);
+ callF387(c17);
+ callF430(c17);
+ callF473(c17);
+ callF516(c17);
+ callF559(c17);
+ callF602(c17);
+ callF645(c17);
+ callF688(c17);
+ callF731(c17);
+ callF0(c17);
+ callF43(c17);
+ }
+ }
+ public void timeConflictDepth19(int nreps) {
+ C18 c18 = new C18();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c18);
+ callF43(c18);
+ callF86(c18);
+ callF129(c18);
+ callF172(c18);
+ callF215(c18);
+ callF258(c18);
+ callF301(c18);
+ callF344(c18);
+ callF387(c18);
+ callF430(c18);
+ callF473(c18);
+ callF516(c18);
+ callF559(c18);
+ callF602(c18);
+ callF645(c18);
+ callF688(c18);
+ callF731(c18);
+ callF774(c18);
+ callF0(c18);
+ }
+ }
+ public void timeConflictDepth20(int nreps) {
+ C19 c19 = new C19();
+ for (int i = 0; i < nreps; i++) {
+ callF0(c19);
+ callF43(c19);
+ callF86(c19);
+ callF129(c19);
+ callF172(c19);
+ callF215(c19);
+ callF258(c19);
+ callF301(c19);
+ callF344(c19);
+ callF387(c19);
+ callF430(c19);
+ callF473(c19);
+ callF516(c19);
+ callF559(c19);
+ callF602(c19);
+ callF645(c19);
+ callF688(c19);
+ callF731(c19);
+ callF774(c19);
+ callF817(c19);
+ }
+ }
+ public void callF0(I0 i) { i.f0(); }
+ public void callF43(I1 i) { i.f43(); }
+ public void callF86(I2 i) { i.f86(); }
+ public void callF129(I3 i) { i.f129(); }
+ public void callF172(I4 i) { i.f172(); }
+ public void callF215(I5 i) { i.f215(); }
+ public void callF258(I6 i) { i.f258(); }
+ public void callF301(I7 i) { i.f301(); }
+ public void callF344(I8 i) { i.f344(); }
+ public void callF387(I9 i) { i.f387(); }
+ public void callF430(I10 i) { i.f430(); }
+ public void callF473(I11 i) { i.f473(); }
+ public void callF516(I12 i) { i.f516(); }
+ public void callF559(I13 i) { i.f559(); }
+ public void callF602(I14 i) { i.f602(); }
+ public void callF645(I15 i) { i.f645(); }
+ public void callF688(I16 i) { i.f688(); }
+ public void callF731(I17 i) { i.f731(); }
+ public void callF774(I18 i) { i.f774(); }
+ public void callF817(I19 i) { i.f817(); }
+ static class C0 implements I0 {}
+ static class C1 implements I0, I1 {}
+ static class C2 implements I0, I1, I2 {}
+ static class C3 implements I0, I1, I2, I3 {}
+ static class C4 implements I0, I1, I2, I3, I4 {}
+ static class C5 implements I0, I1, I2, I3, I4, I5 {}
+ static class C6 implements I0, I1, I2, I3, I4, I5, I6 {}
+ static class C7 implements I0, I1, I2, I3, I4, I5, I6, I7 {}
+ static class C8 implements I0, I1, I2, I3, I4, I5, I6, I7, I8 {}
+ static class C9 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9 {}
+ static class C10 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10 {}
+ static class C11 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11 {}
+ static class C12 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12 {}
+ static class C13 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13 {}
+ static class C14 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14 {}
+ static class C15 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15 {}
+ static class C16 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16 {}
+ static class C17 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17 {}
+ static class C18 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18 {}
+ static class C19 implements I0, I1, I2, I3, I4, I5, I6, I7, I8, I9, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19 {}
+ static interface I0 {
+ default void f0() {}
+ default void f1() {}
+ default void f2() {}
+ default void f3() {}
+ default void f4() {}
+ default void f5() {}
+ default void f6() {}
+ default void f7() {}
+ default void f8() {}
+ default void f9() {}
+ default void f10() {}
+ default void f11() {}
+ default void f12() {}
+ default void f13() {}
+ default void f14() {}
+ default void f15() {}
+ default void f16() {}
+ default void f17() {}
+ default void f18() {}
+ default void f19() {}
+ default void f20() {}
+ default void f21() {}
+ default void f22() {}
+ default void f23() {}
+ default void f24() {}
+ default void f25() {}
+ default void f26() {}
+ default void f27() {}
+ default void f28() {}
+ default void f29() {}
+ default void f30() {}
+ default void f31() {}
+ default void f32() {}
+ default void f33() {}
+ default void f34() {}
+ default void f35() {}
+ default void f36() {}
+ default void f37() {}
+ default void f38() {}
+ default void f39() {}
+ default void f40() {}
+ default void f41() {}
+ default void f42() {}
+ }
+ static interface I1 {
+ default void f43() {}
+ default void f44() {}
+ default void f45() {}
+ default void f46() {}
+ default void f47() {}
+ default void f48() {}
+ default void f49() {}
+ default void f50() {}
+ default void f51() {}
+ default void f52() {}
+ default void f53() {}
+ default void f54() {}
+ default void f55() {}
+ default void f56() {}
+ default void f57() {}
+ default void f58() {}
+ default void f59() {}
+ default void f60() {}
+ default void f61() {}
+ default void f62() {}
+ default void f63() {}
+ default void f64() {}
+ default void f65() {}
+ default void f66() {}
+ default void f67() {}
+ default void f68() {}
+ default void f69() {}
+ default void f70() {}
+ default void f71() {}
+ default void f72() {}
+ default void f73() {}
+ default void f74() {}
+ default void f75() {}
+ default void f76() {}
+ default void f77() {}
+ default void f78() {}
+ default void f79() {}
+ default void f80() {}
+ default void f81() {}
+ default void f82() {}
+ default void f83() {}
+ default void f84() {}
+ default void f85() {}
+ }
+ static interface I2 {
+ default void f86() {}
+ default void f87() {}
+ default void f88() {}
+ default void f89() {}
+ default void f90() {}
+ default void f91() {}
+ default void f92() {}
+ default void f93() {}
+ default void f94() {}
+ default void f95() {}
+ default void f96() {}
+ default void f97() {}
+ default void f98() {}
+ default void f99() {}
+ default void f100() {}
+ default void f101() {}
+ default void f102() {}
+ default void f103() {}
+ default void f104() {}
+ default void f105() {}
+ default void f106() {}
+ default void f107() {}
+ default void f108() {}
+ default void f109() {}
+ default void f110() {}
+ default void f111() {}
+ default void f112() {}
+ default void f113() {}
+ default void f114() {}
+ default void f115() {}
+ default void f116() {}
+ default void f117() {}
+ default void f118() {}
+ default void f119() {}
+ default void f120() {}
+ default void f121() {}
+ default void f122() {}
+ default void f123() {}
+ default void f124() {}
+ default void f125() {}
+ default void f126() {}
+ default void f127() {}
+ default void f128() {}
+ }
+ static interface I3 {
+ default void f129() {}
+ default void f130() {}
+ default void f131() {}
+ default void f132() {}
+ default void f133() {}
+ default void f134() {}
+ default void f135() {}
+ default void f136() {}
+ default void f137() {}
+ default void f138() {}
+ default void f139() {}
+ default void f140() {}
+ default void f141() {}
+ default void f142() {}
+ default void f143() {}
+ default void f144() {}
+ default void f145() {}
+ default void f146() {}
+ default void f147() {}
+ default void f148() {}
+ default void f149() {}
+ default void f150() {}
+ default void f151() {}
+ default void f152() {}
+ default void f153() {}
+ default void f154() {}
+ default void f155() {}
+ default void f156() {}
+ default void f157() {}
+ default void f158() {}
+ default void f159() {}
+ default void f160() {}
+ default void f161() {}
+ default void f162() {}
+ default void f163() {}
+ default void f164() {}
+ default void f165() {}
+ default void f166() {}
+ default void f167() {}
+ default void f168() {}
+ default void f169() {}
+ default void f170() {}
+ default void f171() {}
+ }
+ static interface I4 {
+ default void f172() {}
+ default void f173() {}
+ default void f174() {}
+ default void f175() {}
+ default void f176() {}
+ default void f177() {}
+ default void f178() {}
+ default void f179() {}
+ default void f180() {}
+ default void f181() {}
+ default void f182() {}
+ default void f183() {}
+ default void f184() {}
+ default void f185() {}
+ default void f186() {}
+ default void f187() {}
+ default void f188() {}
+ default void f189() {}
+ default void f190() {}
+ default void f191() {}
+ default void f192() {}
+ default void f193() {}
+ default void f194() {}
+ default void f195() {}
+ default void f196() {}
+ default void f197() {}
+ default void f198() {}
+ default void f199() {}
+ default void f200() {}
+ default void f201() {}
+ default void f202() {}
+ default void f203() {}
+ default void f204() {}
+ default void f205() {}
+ default void f206() {}
+ default void f207() {}
+ default void f208() {}
+ default void f209() {}
+ default void f210() {}
+ default void f211() {}
+ default void f212() {}
+ default void f213() {}
+ default void f214() {}
+ }
+ static interface I5 {
+ default void f215() {}
+ default void f216() {}
+ default void f217() {}
+ default void f218() {}
+ default void f219() {}
+ default void f220() {}
+ default void f221() {}
+ default void f222() {}
+ default void f223() {}
+ default void f224() {}
+ default void f225() {}
+ default void f226() {}
+ default void f227() {}
+ default void f228() {}
+ default void f229() {}
+ default void f230() {}
+ default void f231() {}
+ default void f232() {}
+ default void f233() {}
+ default void f234() {}
+ default void f235() {}
+ default void f236() {}
+ default void f237() {}
+ default void f238() {}
+ default void f239() {}
+ default void f240() {}
+ default void f241() {}
+ default void f242() {}
+ default void f243() {}
+ default void f244() {}
+ default void f245() {}
+ default void f246() {}
+ default void f247() {}
+ default void f248() {}
+ default void f249() {}
+ default void f250() {}
+ default void f251() {}
+ default void f252() {}
+ default void f253() {}
+ default void f254() {}
+ default void f255() {}
+ default void f256() {}
+ default void f257() {}
+ }
+ static interface I6 {
+ default void f258() {}
+ default void f259() {}
+ default void f260() {}
+ default void f261() {}
+ default void f262() {}
+ default void f263() {}
+ default void f264() {}
+ default void f265() {}
+ default void f266() {}
+ default void f267() {}
+ default void f268() {}
+ default void f269() {}
+ default void f270() {}
+ default void f271() {}
+ default void f272() {}
+ default void f273() {}
+ default void f274() {}
+ default void f275() {}
+ default void f276() {}
+ default void f277() {}
+ default void f278() {}
+ default void f279() {}
+ default void f280() {}
+ default void f281() {}
+ default void f282() {}
+ default void f283() {}
+ default void f284() {}
+ default void f285() {}
+ default void f286() {}
+ default void f287() {}
+ default void f288() {}
+ default void f289() {}
+ default void f290() {}
+ default void f291() {}
+ default void f292() {}
+ default void f293() {}
+ default void f294() {}
+ default void f295() {}
+ default void f296() {}
+ default void f297() {}
+ default void f298() {}
+ default void f299() {}
+ default void f300() {}
+ }
+ static interface I7 {
+ default void f301() {}
+ default void f302() {}
+ default void f303() {}
+ default void f304() {}
+ default void f305() {}
+ default void f306() {}
+ default void f307() {}
+ default void f308() {}
+ default void f309() {}
+ default void f310() {}
+ default void f311() {}
+ default void f312() {}
+ default void f313() {}
+ default void f314() {}
+ default void f315() {}
+ default void f316() {}
+ default void f317() {}
+ default void f318() {}
+ default void f319() {}
+ default void f320() {}
+ default void f321() {}
+ default void f322() {}
+ default void f323() {}
+ default void f324() {}
+ default void f325() {}
+ default void f326() {}
+ default void f327() {}
+ default void f328() {}
+ default void f329() {}
+ default void f330() {}
+ default void f331() {}
+ default void f332() {}
+ default void f333() {}
+ default void f334() {}
+ default void f335() {}
+ default void f336() {}
+ default void f337() {}
+ default void f338() {}
+ default void f339() {}
+ default void f340() {}
+ default void f341() {}
+ default void f342() {}
+ default void f343() {}
+ }
+ static interface I8 {
+ default void f344() {}
+ default void f345() {}
+ default void f346() {}
+ default void f347() {}
+ default void f348() {}
+ default void f349() {}
+ default void f350() {}
+ default void f351() {}
+ default void f352() {}
+ default void f353() {}
+ default void f354() {}
+ default void f355() {}
+ default void f356() {}
+ default void f357() {}
+ default void f358() {}
+ default void f359() {}
+ default void f360() {}
+ default void f361() {}
+ default void f362() {}
+ default void f363() {}
+ default void f364() {}
+ default void f365() {}
+ default void f366() {}
+ default void f367() {}
+ default void f368() {}
+ default void f369() {}
+ default void f370() {}
+ default void f371() {}
+ default void f372() {}
+ default void f373() {}
+ default void f374() {}
+ default void f375() {}
+ default void f376() {}
+ default void f377() {}
+ default void f378() {}
+ default void f379() {}
+ default void f380() {}
+ default void f381() {}
+ default void f382() {}
+ default void f383() {}
+ default void f384() {}
+ default void f385() {}
+ default void f386() {}
+ }
+ static interface I9 {
+ default void f387() {}
+ default void f388() {}
+ default void f389() {}
+ default void f390() {}
+ default void f391() {}
+ default void f392() {}
+ default void f393() {}
+ default void f394() {}
+ default void f395() {}
+ default void f396() {}
+ default void f397() {}
+ default void f398() {}
+ default void f399() {}
+ default void f400() {}
+ default void f401() {}
+ default void f402() {}
+ default void f403() {}
+ default void f404() {}
+ default void f405() {}
+ default void f406() {}
+ default void f407() {}
+ default void f408() {}
+ default void f409() {}
+ default void f410() {}
+ default void f411() {}
+ default void f412() {}
+ default void f413() {}
+ default void f414() {}
+ default void f415() {}
+ default void f416() {}
+ default void f417() {}
+ default void f418() {}
+ default void f419() {}
+ default void f420() {}
+ default void f421() {}
+ default void f422() {}
+ default void f423() {}
+ default void f424() {}
+ default void f425() {}
+ default void f426() {}
+ default void f427() {}
+ default void f428() {}
+ default void f429() {}
+ }
+ static interface I10 {
+ default void f430() {}
+ default void f431() {}
+ default void f432() {}
+ default void f433() {}
+ default void f434() {}
+ default void f435() {}
+ default void f436() {}
+ default void f437() {}
+ default void f438() {}
+ default void f439() {}
+ default void f440() {}
+ default void f441() {}
+ default void f442() {}
+ default void f443() {}
+ default void f444() {}
+ default void f445() {}
+ default void f446() {}
+ default void f447() {}
+ default void f448() {}
+ default void f449() {}
+ default void f450() {}
+ default void f451() {}
+ default void f452() {}
+ default void f453() {}
+ default void f454() {}
+ default void f455() {}
+ default void f456() {}
+ default void f457() {}
+ default void f458() {}
+ default void f459() {}
+ default void f460() {}
+ default void f461() {}
+ default void f462() {}
+ default void f463() {}
+ default void f464() {}
+ default void f465() {}
+ default void f466() {}
+ default void f467() {}
+ default void f468() {}
+ default void f469() {}
+ default void f470() {}
+ default void f471() {}
+ default void f472() {}
+ }
+ static interface I11 {
+ default void f473() {}
+ default void f474() {}
+ default void f475() {}
+ default void f476() {}
+ default void f477() {}
+ default void f478() {}
+ default void f479() {}
+ default void f480() {}
+ default void f481() {}
+ default void f482() {}
+ default void f483() {}
+ default void f484() {}
+ default void f485() {}
+ default void f486() {}
+ default void f487() {}
+ default void f488() {}
+ default void f489() {}
+ default void f490() {}
+ default void f491() {}
+ default void f492() {}
+ default void f493() {}
+ default void f494() {}
+ default void f495() {}
+ default void f496() {}
+ default void f497() {}
+ default void f498() {}
+ default void f499() {}
+ default void f500() {}
+ default void f501() {}
+ default void f502() {}
+ default void f503() {}
+ default void f504() {}
+ default void f505() {}
+ default void f506() {}
+ default void f507() {}
+ default void f508() {}
+ default void f509() {}
+ default void f510() {}
+ default void f511() {}
+ default void f512() {}
+ default void f513() {}
+ default void f514() {}
+ default void f515() {}
+ }
+ static interface I12 {
+ default void f516() {}
+ default void f517() {}
+ default void f518() {}
+ default void f519() {}
+ default void f520() {}
+ default void f521() {}
+ default void f522() {}
+ default void f523() {}
+ default void f524() {}
+ default void f525() {}
+ default void f526() {}
+ default void f527() {}
+ default void f528() {}
+ default void f529() {}
+ default void f530() {}
+ default void f531() {}
+ default void f532() {}
+ default void f533() {}
+ default void f534() {}
+ default void f535() {}
+ default void f536() {}
+ default void f537() {}
+ default void f538() {}
+ default void f539() {}
+ default void f540() {}
+ default void f541() {}
+ default void f542() {}
+ default void f543() {}
+ default void f544() {}
+ default void f545() {}
+ default void f546() {}
+ default void f547() {}
+ default void f548() {}
+ default void f549() {}
+ default void f550() {}
+ default void f551() {}
+ default void f552() {}
+ default void f553() {}
+ default void f554() {}
+ default void f555() {}
+ default void f556() {}
+ default void f557() {}
+ default void f558() {}
+ }
+ static interface I13 {
+ default void f559() {}
+ default void f560() {}
+ default void f561() {}
+ default void f562() {}
+ default void f563() {}
+ default void f564() {}
+ default void f565() {}
+ default void f566() {}
+ default void f567() {}
+ default void f568() {}
+ default void f569() {}
+ default void f570() {}
+ default void f571() {}
+ default void f572() {}
+ default void f573() {}
+ default void f574() {}
+ default void f575() {}
+ default void f576() {}
+ default void f577() {}
+ default void f578() {}
+ default void f579() {}
+ default void f580() {}
+ default void f581() {}
+ default void f582() {}
+ default void f583() {}
+ default void f584() {}
+ default void f585() {}
+ default void f586() {}
+ default void f587() {}
+ default void f588() {}
+ default void f589() {}
+ default void f590() {}
+ default void f591() {}
+ default void f592() {}
+ default void f593() {}
+ default void f594() {}
+ default void f595() {}
+ default void f596() {}
+ default void f597() {}
+ default void f598() {}
+ default void f599() {}
+ default void f600() {}
+ default void f601() {}
+ }
+ static interface I14 {
+ default void f602() {}
+ default void f603() {}
+ default void f604() {}
+ default void f605() {}
+ default void f606() {}
+ default void f607() {}
+ default void f608() {}
+ default void f609() {}
+ default void f610() {}
+ default void f611() {}
+ default void f612() {}
+ default void f613() {}
+ default void f614() {}
+ default void f615() {}
+ default void f616() {}
+ default void f617() {}
+ default void f618() {}
+ default void f619() {}
+ default void f620() {}
+ default void f621() {}
+ default void f622() {}
+ default void f623() {}
+ default void f624() {}
+ default void f625() {}
+ default void f626() {}
+ default void f627() {}
+ default void f628() {}
+ default void f629() {}
+ default void f630() {}
+ default void f631() {}
+ default void f632() {}
+ default void f633() {}
+ default void f634() {}
+ default void f635() {}
+ default void f636() {}
+ default void f637() {}
+ default void f638() {}
+ default void f639() {}
+ default void f640() {}
+ default void f641() {}
+ default void f642() {}
+ default void f643() {}
+ default void f644() {}
+ }
+ static interface I15 {
+ default void f645() {}
+ default void f646() {}
+ default void f647() {}
+ default void f648() {}
+ default void f649() {}
+ default void f650() {}
+ default void f651() {}
+ default void f652() {}
+ default void f653() {}
+ default void f654() {}
+ default void f655() {}
+ default void f656() {}
+ default void f657() {}
+ default void f658() {}
+ default void f659() {}
+ default void f660() {}
+ default void f661() {}
+ default void f662() {}
+ default void f663() {}
+ default void f664() {}
+ default void f665() {}
+ default void f666() {}
+ default void f667() {}
+ default void f668() {}
+ default void f669() {}
+ default void f670() {}
+ default void f671() {}
+ default void f672() {}
+ default void f673() {}
+ default void f674() {}
+ default void f675() {}
+ default void f676() {}
+ default void f677() {}
+ default void f678() {}
+ default void f679() {}
+ default void f680() {}
+ default void f681() {}
+ default void f682() {}
+ default void f683() {}
+ default void f684() {}
+ default void f685() {}
+ default void f686() {}
+ default void f687() {}
+ }
+ static interface I16 {
+ default void f688() {}
+ default void f689() {}
+ default void f690() {}
+ default void f691() {}
+ default void f692() {}
+ default void f693() {}
+ default void f694() {}
+ default void f695() {}
+ default void f696() {}
+ default void f697() {}
+ default void f698() {}
+ default void f699() {}
+ default void f700() {}
+ default void f701() {}
+ default void f702() {}
+ default void f703() {}
+ default void f704() {}
+ default void f705() {}
+ default void f706() {}
+ default void f707() {}
+ default void f708() {}
+ default void f709() {}
+ default void f710() {}
+ default void f711() {}
+ default void f712() {}
+ default void f713() {}
+ default void f714() {}
+ default void f715() {}
+ default void f716() {}
+ default void f717() {}
+ default void f718() {}
+ default void f719() {}
+ default void f720() {}
+ default void f721() {}
+ default void f722() {}
+ default void f723() {}
+ default void f724() {}
+ default void f725() {}
+ default void f726() {}
+ default void f727() {}
+ default void f728() {}
+ default void f729() {}
+ default void f730() {}
+ }
+ static interface I17 {
+ default void f731() {}
+ default void f732() {}
+ default void f733() {}
+ default void f734() {}
+ default void f735() {}
+ default void f736() {}
+ default void f737() {}
+ default void f738() {}
+ default void f739() {}
+ default void f740() {}
+ default void f741() {}
+ default void f742() {}
+ default void f743() {}
+ default void f744() {}
+ default void f745() {}
+ default void f746() {}
+ default void f747() {}
+ default void f748() {}
+ default void f749() {}
+ default void f750() {}
+ default void f751() {}
+ default void f752() {}
+ default void f753() {}
+ default void f754() {}
+ default void f755() {}
+ default void f756() {}
+ default void f757() {}
+ default void f758() {}
+ default void f759() {}
+ default void f760() {}
+ default void f761() {}
+ default void f762() {}
+ default void f763() {}
+ default void f764() {}
+ default void f765() {}
+ default void f766() {}
+ default void f767() {}
+ default void f768() {}
+ default void f769() {}
+ default void f770() {}
+ default void f771() {}
+ default void f772() {}
+ default void f773() {}
+ }
+ static interface I18 {
+ default void f774() {}
+ default void f775() {}
+ default void f776() {}
+ default void f777() {}
+ default void f778() {}
+ default void f779() {}
+ default void f780() {}
+ default void f781() {}
+ default void f782() {}
+ default void f783() {}
+ default void f784() {}
+ default void f785() {}
+ default void f786() {}
+ default void f787() {}
+ default void f788() {}
+ default void f789() {}
+ default void f790() {}
+ default void f791() {}
+ default void f792() {}
+ default void f793() {}
+ default void f794() {}
+ default void f795() {}
+ default void f796() {}
+ default void f797() {}
+ default void f798() {}
+ default void f799() {}
+ default void f800() {}
+ default void f801() {}
+ default void f802() {}
+ default void f803() {}
+ default void f804() {}
+ default void f805() {}
+ default void f806() {}
+ default void f807() {}
+ default void f808() {}
+ default void f809() {}
+ default void f810() {}
+ default void f811() {}
+ default void f812() {}
+ default void f813() {}
+ default void f814() {}
+ default void f815() {}
+ default void f816() {}
+ }
+ static interface I19 {
+ default void f817() {}
+ default void f818() {}
+ default void f819() {}
+ default void f820() {}
+ default void f821() {}
+ default void f822() {}
+ default void f823() {}
+ default void f824() {}
+ default void f825() {}
+ default void f826() {}
+ default void f827() {}
+ default void f828() {}
+ default void f829() {}
+ default void f830() {}
+ default void f831() {}
+ default void f832() {}
+ default void f833() {}
+ default void f834() {}
+ default void f835() {}
+ default void f836() {}
+ default void f837() {}
+ default void f838() {}
+ default void f839() {}
+ default void f840() {}
+ default void f841() {}
+ default void f842() {}
+ default void f843() {}
+ default void f844() {}
+ default void f845() {}
+ default void f846() {}
+ default void f847() {}
+ default void f848() {}
+ default void f849() {}
+ default void f850() {}
+ default void f851() {}
+ default void f852() {}
+ default void f853() {}
+ default void f854() {}
+ default void f855() {}
+ default void f856() {}
+ default void f857() {}
+ default void f858() {}
+ default void f859() {}
+ }
+}
diff --git a/benchmarks/InvokeInterface.java b/benchmarks/InvokeInterface.java
new file mode 100644
index 0000000..a9c3c28
--- /dev/null
+++ b/benchmarks/InvokeInterface.java
@@ -0,0 +1,641 @@
+/*
+ * Copyright 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+public class InvokeInterface {
+ static MultiClass multi;
+
+ static {
+ multi = new MultiClass();
+ }
+
+ public void timeCall0Concrete(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall0Concrete(m);
+ }
+ }
+
+ public void timeCall0Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall0Interface(m);
+ }
+ }
+
+ public void timeCall1Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall1Interface(m);
+ }
+ }
+
+ public void timeCall2Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall2Interface(m);
+ }
+ }
+
+ public void timeCall3Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall3Interface(m);
+ }
+ }
+
+ public void timeCall4Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall4Interface(m);
+ }
+ }
+
+ public void timeCall5Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall5Interface(m);
+ }
+ }
+
+ public void timeCall6Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall6Interface(m);
+ }
+ }
+
+ public void timeCall7Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall7Interface(m);
+ }
+ }
+
+ public void timeCall8Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall8Interface(m);
+ }
+ }
+
+ public void timeCall9Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall9Interface(m);
+ }
+ }
+
+ public void timeCall10Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall10Interface(m);
+ }
+ }
+
+ public void timeCall11Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall11Interface(m);
+ }
+ }
+
+ public void timeCall12Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall12Interface(m);
+ }
+ }
+
+ public void timeCall13Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall13Interface(m);
+ }
+ }
+
+ public void timeCall14Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall14Interface(m);
+ }
+ }
+
+ public void timeCall15Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall15Interface(m);
+ }
+ }
+
+ public void timeCall16Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall16Interface(m);
+ }
+ }
+
+ public void timeCall17Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall17Interface(m);
+ }
+ }
+
+ public void timeCall18Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall18Interface(m);
+ }
+ }
+
+ public void timeCall19Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall19Interface(m);
+ }
+ }
+
+ public void timeCall20Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall20Interface(m);
+ }
+ }
+
+ public void timeCall21Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall21Interface(m);
+ }
+ }
+
+ public void timeCall22Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall22Interface(m);
+ }
+ }
+
+ public void timeCall23Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall23Interface(m);
+ }
+ }
+
+ public void timeCall24Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall24Interface(m);
+ }
+ }
+
+ public void timeCall25Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall25Interface(m);
+ }
+ }
+
+ public void timeCall26Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall26Interface(m);
+ }
+ }
+
+ public void timeCall27Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall27Interface(m);
+ }
+ }
+
+ public void timeCall28Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall28Interface(m);
+ }
+ }
+
+ public void timeCall29Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall29Interface(m);
+ }
+ }
+
+ public void timeCall30Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall30Interface(m);
+ }
+ }
+
+ public void timeCall31Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall31Interface(m);
+ }
+ }
+
+ public void timeCall32Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall32Interface(m);
+ }
+ }
+
+ public void timeCall33Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall33Interface(m);
+ }
+ }
+
+ public void timeCall34Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall34Interface(m);
+ }
+ }
+
+ public void timeCall35Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall35Interface(m);
+ }
+ }
+
+ public void timeCall36Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall36Interface(m);
+ }
+ }
+
+ public void timeCall37Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall37Interface(m);
+ }
+ }
+
+ public void timeCall38Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall38Interface(m);
+ }
+ }
+
+ public void timeCall39Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall39Interface(m);
+ }
+ }
+
+ public void timeCall40Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall40Interface(m);
+ }
+ }
+
+ public void timeCall41Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall41Interface(m);
+ }
+ }
+
+ public void timeCall42Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall42Interface(m);
+ }
+ }
+
+ public void timeCall43Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall43Interface(m);
+ }
+ }
+
+ public void timeCall44Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall44Interface(m);
+ }
+ }
+
+ public void timeCall45Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall45Interface(m);
+ }
+ }
+
+ public void timeCall46Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall46Interface(m);
+ }
+ }
+
+ public void timeCall47Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall47Interface(m);
+ }
+ }
+
+ public void timeCall48Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall48Interface(m);
+ }
+ }
+
+ public void timeCall49Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall49Interface(m);
+ }
+ }
+
+ public void timeCall50Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall50Interface(m);
+ }
+ }
+
+ public void timeCall51Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall51Interface(m);
+ }
+ }
+
+ public void timeCall52Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall52Interface(m);
+ }
+ }
+
+ public void timeCall53Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall53Interface(m);
+ }
+ }
+
+ public void timeCall54Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall54Interface(m);
+ }
+ }
+
+ public void timeCall55Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall55Interface(m);
+ }
+ }
+
+ public void timeCall56Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall56Interface(m);
+ }
+ }
+
+ public void timeCall57Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall57Interface(m);
+ }
+ }
+
+ public void timeCall58Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall58Interface(m);
+ }
+ }
+
+ public void timeCall59Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall59Interface(m);
+ }
+ }
+
+ public void timeCall60Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall60Interface(m);
+ }
+ }
+
+ public void timeCall61Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall61Interface(m);
+ }
+ }
+
+ public void timeCall62Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall62Interface(m);
+ }
+ }
+
+ public void timeCall63Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall63Interface(m);
+ }
+ }
+
+ public void timeCall64Interface(int nreps) {
+ MultiClass m = multi;
+ for (int i = 0; i < nreps; i++) {
+ doCall64Interface(m);
+ }
+ }
+
+ // Try calling these through the IMT/IfTable
+ public void doCall0Interface(Iface0 i) { i.callIface0(); }
+ public void doCall1Interface(Iface1 i) { i.callIface1(); }
+ public void doCall2Interface(Iface2 i) { i.callIface2(); }
+ public void doCall3Interface(Iface3 i) { i.callIface3(); }
+ public void doCall4Interface(Iface4 i) { i.callIface4(); }
+ public void doCall5Interface(Iface5 i) { i.callIface5(); }
+ public void doCall6Interface(Iface6 i) { i.callIface6(); }
+ public void doCall7Interface(Iface7 i) { i.callIface7(); }
+ public void doCall8Interface(Iface8 i) { i.callIface8(); }
+ public void doCall9Interface(Iface9 i) { i.callIface9(); }
+ public void doCall10Interface(Iface10 i) { i.callIface10(); }
+ public void doCall11Interface(Iface11 i) { i.callIface11(); }
+ public void doCall12Interface(Iface12 i) { i.callIface12(); }
+ public void doCall13Interface(Iface13 i) { i.callIface13(); }
+ public void doCall14Interface(Iface14 i) { i.callIface14(); }
+ public void doCall15Interface(Iface15 i) { i.callIface15(); }
+ public void doCall16Interface(Iface16 i) { i.callIface16(); }
+ public void doCall17Interface(Iface17 i) { i.callIface17(); }
+ public void doCall18Interface(Iface18 i) { i.callIface18(); }
+ public void doCall19Interface(Iface19 i) { i.callIface19(); }
+ public void doCall20Interface(Iface20 i) { i.callIface20(); }
+ public void doCall21Interface(Iface21 i) { i.callIface21(); }
+ public void doCall22Interface(Iface22 i) { i.callIface22(); }
+ public void doCall23Interface(Iface23 i) { i.callIface23(); }
+ public void doCall24Interface(Iface24 i) { i.callIface24(); }
+ public void doCall25Interface(Iface25 i) { i.callIface25(); }
+ public void doCall26Interface(Iface26 i) { i.callIface26(); }
+ public void doCall27Interface(Iface27 i) { i.callIface27(); }
+ public void doCall28Interface(Iface28 i) { i.callIface28(); }
+ public void doCall29Interface(Iface29 i) { i.callIface29(); }
+ public void doCall30Interface(Iface30 i) { i.callIface30(); }
+ public void doCall31Interface(Iface31 i) { i.callIface31(); }
+ public void doCall32Interface(Iface32 i) { i.callIface32(); }
+ public void doCall33Interface(Iface33 i) { i.callIface33(); }
+ public void doCall34Interface(Iface34 i) { i.callIface34(); }
+ public void doCall35Interface(Iface35 i) { i.callIface35(); }
+ public void doCall36Interface(Iface36 i) { i.callIface36(); }
+ public void doCall37Interface(Iface37 i) { i.callIface37(); }
+ public void doCall38Interface(Iface38 i) { i.callIface38(); }
+ public void doCall39Interface(Iface39 i) { i.callIface39(); }
+ public void doCall40Interface(Iface40 i) { i.callIface40(); }
+ public void doCall41Interface(Iface41 i) { i.callIface41(); }
+ public void doCall42Interface(Iface42 i) { i.callIface42(); }
+ public void doCall43Interface(Iface43 i) { i.callIface43(); }
+ public void doCall44Interface(Iface44 i) { i.callIface44(); }
+ public void doCall45Interface(Iface45 i) { i.callIface45(); }
+ public void doCall46Interface(Iface46 i) { i.callIface46(); }
+ public void doCall47Interface(Iface47 i) { i.callIface47(); }
+ public void doCall48Interface(Iface48 i) { i.callIface48(); }
+ public void doCall49Interface(Iface49 i) { i.callIface49(); }
+ public void doCall50Interface(Iface50 i) { i.callIface50(); }
+ public void doCall51Interface(Iface51 i) { i.callIface51(); }
+ public void doCall52Interface(Iface52 i) { i.callIface52(); }
+ public void doCall53Interface(Iface53 i) { i.callIface53(); }
+ public void doCall54Interface(Iface54 i) { i.callIface54(); }
+ public void doCall55Interface(Iface55 i) { i.callIface55(); }
+ public void doCall56Interface(Iface56 i) { i.callIface56(); }
+ public void doCall57Interface(Iface57 i) { i.callIface57(); }
+ public void doCall58Interface(Iface58 i) { i.callIface58(); }
+ public void doCall59Interface(Iface59 i) { i.callIface59(); }
+ public void doCall60Interface(Iface60 i) { i.callIface60(); }
+ public void doCall61Interface(Iface61 i) { i.callIface61(); }
+ public void doCall62Interface(Iface62 i) { i.callIface62(); }
+ public void doCall63Interface(Iface63 i) { i.callIface63(); }
+ public void doCall64Interface(Iface64 i) { i.callIface64(); }
+
+ // Try calling this through the vtable for comparison.
+ public void doCall0Concrete(MultiClass m) { m.callIface0(); }
+
+ // IMTs are 64 entries in length. By making this 65 interfaces we guarantee that we will have a
+ // collision.
+ static class MultiClass implements Iface0, Iface1, Iface2, Iface3, Iface4,
+ Iface5, Iface6, Iface7, Iface8, Iface9,
+ Iface10, Iface11, Iface12, Iface13, Iface14,
+ Iface15, Iface16, Iface17, Iface18, Iface19,
+ Iface20, Iface21, Iface22, Iface23, Iface24,
+ Iface25, Iface26, Iface27, Iface28, Iface29,
+ Iface30, Iface31, Iface32, Iface33, Iface34,
+ Iface35, Iface36, Iface37, Iface38, Iface39,
+ Iface40, Iface41, Iface42, Iface43, Iface44,
+ Iface45, Iface46, Iface47, Iface48, Iface49,
+ Iface50, Iface51, Iface52, Iface53, Iface54,
+ Iface55, Iface56, Iface57, Iface58, Iface59,
+ Iface60, Iface61, Iface62, Iface63, Iface64 { }
+
+ // The declaration of the 64 interfaces. We give them all default methods to avoid having to
+ // repeat ourselves.
+ static interface Iface0 { default void callIface0() {} }
+ static interface Iface1 { default void callIface1() {} }
+ static interface Iface2 { default void callIface2() {} }
+ static interface Iface3 { default void callIface3() {} }
+ static interface Iface4 { default void callIface4() {} }
+ static interface Iface5 { default void callIface5() {} }
+ static interface Iface6 { default void callIface6() {} }
+ static interface Iface7 { default void callIface7() {} }
+ static interface Iface8 { default void callIface8() {} }
+ static interface Iface9 { default void callIface9() {} }
+ static interface Iface10 { default void callIface10() {} }
+ static interface Iface11 { default void callIface11() {} }
+ static interface Iface12 { default void callIface12() {} }
+ static interface Iface13 { default void callIface13() {} }
+ static interface Iface14 { default void callIface14() {} }
+ static interface Iface15 { default void callIface15() {} }
+ static interface Iface16 { default void callIface16() {} }
+ static interface Iface17 { default void callIface17() {} }
+ static interface Iface18 { default void callIface18() {} }
+ static interface Iface19 { default void callIface19() {} }
+ static interface Iface20 { default void callIface20() {} }
+ static interface Iface21 { default void callIface21() {} }
+ static interface Iface22 { default void callIface22() {} }
+ static interface Iface23 { default void callIface23() {} }
+ static interface Iface24 { default void callIface24() {} }
+ static interface Iface25 { default void callIface25() {} }
+ static interface Iface26 { default void callIface26() {} }
+ static interface Iface27 { default void callIface27() {} }
+ static interface Iface28 { default void callIface28() {} }
+ static interface Iface29 { default void callIface29() {} }
+ static interface Iface30 { default void callIface30() {} }
+ static interface Iface31 { default void callIface31() {} }
+ static interface Iface32 { default void callIface32() {} }
+ static interface Iface33 { default void callIface33() {} }
+ static interface Iface34 { default void callIface34() {} }
+ static interface Iface35 { default void callIface35() {} }
+ static interface Iface36 { default void callIface36() {} }
+ static interface Iface37 { default void callIface37() {} }
+ static interface Iface38 { default void callIface38() {} }
+ static interface Iface39 { default void callIface39() {} }
+ static interface Iface40 { default void callIface40() {} }
+ static interface Iface41 { default void callIface41() {} }
+ static interface Iface42 { default void callIface42() {} }
+ static interface Iface43 { default void callIface43() {} }
+ static interface Iface44 { default void callIface44() {} }
+ static interface Iface45 { default void callIface45() {} }
+ static interface Iface46 { default void callIface46() {} }
+ static interface Iface47 { default void callIface47() {} }
+ static interface Iface48 { default void callIface48() {} }
+ static interface Iface49 { default void callIface49() {} }
+ static interface Iface50 { default void callIface50() {} }
+ static interface Iface51 { default void callIface51() {} }
+ static interface Iface52 { default void callIface52() {} }
+ static interface Iface53 { default void callIface53() {} }
+ static interface Iface54 { default void callIface54() {} }
+ static interface Iface55 { default void callIface55() {} }
+ static interface Iface56 { default void callIface56() {} }
+ static interface Iface57 { default void callIface57() {} }
+ static interface Iface58 { default void callIface58() {} }
+ static interface Iface59 { default void callIface59() {} }
+ static interface Iface60 { default void callIface60() {} }
+ static interface Iface61 { default void callIface61() {} }
+ static interface Iface62 { default void callIface62() {} }
+ static interface Iface63 { default void callIface63() {} }
+ static interface Iface64 { default void callIface64() {} }
+}
diff --git a/benchmarks/LocaleDataBenchmark.java b/benchmarks/LocaleDataBenchmark.java
new file mode 100644
index 0000000..adf6768
--- /dev/null
+++ b/benchmarks/LocaleDataBenchmark.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Benchmark;
+import java.util.Locale;
+import libcore.icu.LocaleData;
+
+public final class LocaleDataBenchmark {
+ private static final Locale[] TEST_LOCALES = new Locale[] {
+ Locale.forLanguageTag("en-US"),
+ Locale.forLanguageTag("jp-JP"),
+ Locale.forLanguageTag("es-419"),
+ Locale.forLanguageTag("ar-EG"),
+ Locale.forLanguageTag("zh-CN"),
+ };
+
+ public void timeInitLocaleData(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (Locale locale : TEST_LOCALES) {
+ LocaleData.initLocaleData(locale);
+ }
+ }
+ }
+}
diff --git a/benchmarks/MethodInvocationBenchmark.java b/benchmarks/MethodInvocationBenchmark.java
new file mode 100644
index 0000000..6a023e0
--- /dev/null
+++ b/benchmarks/MethodInvocationBenchmark.java
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * Compares various kinds of method invocation.
+ */
+public class MethodInvocationBenchmark {
+ interface I {
+ void emptyInterface();
+ }
+
+ static class C implements I {
+ private int field;
+
+ private int getField() {
+ return field;
+ }
+
+ public int timeInternalGetter(int reps) {
+ int result = 0;
+ for (int i = 0; i < reps; ++i) {
+ result = getField();
+ }
+ return result;
+ }
+
+ public int timeInternalFieldAccess(int reps) {
+ int result = 0;
+ for (int i = 0; i < reps; ++i) {
+ result = field;
+ }
+ return result;
+ }
+
+ public static void emptyStatic() {
+ }
+
+ public void emptyVirtual() {
+ }
+
+ public void emptyInterface() {
+ }
+ }
+
+ public void timeInternalGetter(int reps) {
+ new C().timeInternalGetter(reps);
+ }
+
+ public void timeInternalFieldAccess(int reps) {
+ new C().timeInternalFieldAccess(reps);
+ }
+
+ // Test an intrinsic.
+ public int timeStringLength(int reps) {
+ int result = 0;
+ for (int i = 0; i < reps; ++i) {
+ result = "hello, world!".length();
+ }
+ return result;
+ }
+
+ public void timeEmptyStatic(int reps) {
+ C c = new C();
+ for (int i = 0; i < reps; ++i) {
+ c.emptyStatic();
+ }
+ }
+
+ public void timeEmptyVirtual(int reps) {
+ C c = new C();
+ for (int i = 0; i < reps; ++i) {
+ c.emptyVirtual();
+ }
+ }
+
+ public void timeEmptyInterface(int reps) {
+ I c = new C();
+ for (int i = 0; i < reps; ++i) {
+ c.emptyInterface();
+ }
+ }
+
+ public static class Inner {
+ private int i;
+ private void privateMethod() { ++i; }
+ protected void protectedMethod() { ++i; }
+ public void publicMethod() { ++i; }
+ void packageMethod() { ++i; }
+ final void finalPackageMethod() { ++i; }
+ }
+
+ public void timePrivateInnerPublicMethod(int reps) {
+ Inner inner = new Inner();
+ for (int i = 0; i < reps; ++i) {
+ inner.publicMethod();
+ }
+ }
+
+ public void timePrivateInnerProtectedMethod(int reps) {
+ Inner inner = new Inner();
+ for (int i = 0; i < reps; ++i) {
+ inner.protectedMethod();
+ }
+ }
+
+ public void timePrivateInnerPrivateMethod(int reps) {
+ Inner inner = new Inner();
+ for (int i = 0; i < reps; ++i) {
+ inner.privateMethod();
+ }
+ }
+
+ public void timePrivateInnerPackageMethod(int reps) {
+ Inner inner = new Inner();
+ for (int i = 0; i < reps; ++i) {
+ inner.packageMethod();
+ }
+ }
+
+ public void timePrivateInnerFinalPackageMethod(int reps) {
+ Inner inner = new Inner();
+ for (int i = 0; i < reps; ++i) {
+ inner.finalPackageMethod();
+ }
+ }
+}
diff --git a/benchmarks/MultiplicationBenchmark.java b/benchmarks/MultiplicationBenchmark.java
new file mode 100644
index 0000000..8dfa628
--- /dev/null
+++ b/benchmarks/MultiplicationBenchmark.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * How much do various kinds of multiplication cost?
+ */
+public class MultiplicationBenchmark {
+ public int timeMultiplyIntByConstant10(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 10;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant8(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 8;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByVariable10(int reps) {
+ int result = 1;
+ int factor = 10;
+ for (int i = 0; i < reps; ++i) {
+ result *= factor;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByVariable8(int reps) {
+ int result = 1;
+ int factor = 8;
+ for (int i = 0; i < reps; ++i) {
+ result *= factor;
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/ReferenceBenchmark.java b/benchmarks/ReferenceBenchmark.java
new file mode 100644
index 0000000..f1b84a3
--- /dev/null
+++ b/benchmarks/ReferenceBenchmark.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Benchmark to evaluate the performance of References.
+ */
+public class ReferenceBenchmark {
+
+ private Object object;
+
+ // How fast can references can be allocated?
+ public void timeAlloc(int reps) {
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ for (int i = 0; i < reps; i++) {
+ new PhantomReference(object, queue);
+ }
+ }
+
+ // How fast can references can be allocated and manually enqueued?
+ public void timeAllocAndEnqueue(int reps) {
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ for (int i = 0; i < reps; i++) {
+ (new PhantomReference<Object>(object, queue)).enqueue();
+ }
+ }
+
+ // How fast can references can be allocated, enqueued, and polled?
+ public void timeAllocEnqueueAndPoll(int reps) {
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ for (int i = 0; i < reps; i++) {
+ (new PhantomReference<Object>(object, queue)).enqueue();
+ }
+ for (int i = 0; i < reps; i++) {
+ queue.poll();
+ }
+ }
+
+ // How fast can references can be allocated, enqueued, and removed?
+ public void timeAllocEnqueueAndRemove(int reps) {
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ for (int i = 0; i < reps; i++) {
+ (new PhantomReference<Object>(object, queue)).enqueue();
+ }
+ for (int i = 0; i < reps; i++) {
+ try {
+ queue.remove();
+ } catch (InterruptedException ie) {
+ i--;
+ }
+ }
+ }
+
+ // How fast can references can be implicitly allocated, enqueued, and
+ // removed?
+ public void timeAllocImplicitEnqueueAndRemove(int reps) {
+ ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
+ List<Object> refs = new ArrayList<Object>();
+ for (int i = 0; i < reps; i++) {
+ refs.add(new PhantomReference<Object>(new Object(), queue));
+ }
+ Runtime.getRuntime().gc();
+ for (int i = 0; i < reps; i++) {
+ try {
+ queue.remove();
+ } catch (InterruptedException ie) {
+ i--;
+ }
+ }
+ }
+
+ static private class FinalizableObject {
+ AtomicInteger count;
+
+ public FinalizableObject(AtomicInteger count) {
+ this.count = count;
+ }
+
+ @Override
+ protected void finalize() {
+ count.incrementAndGet();
+ }
+ }
+
+ // How fast does finalization run?
+ public void timeFinalization(int reps) {
+ // Allocate a bunch of finalizable objects.
+ int n = reps;
+ AtomicInteger count = new AtomicInteger(0);
+ for (int i = 0; i < n; i++) {
+ new FinalizableObject(count);
+ }
+
+ // Run GC so the objects will be collected for finalization.
+ Runtime.getRuntime().gc();
+
+ // Wait for finalization.
+ Runtime.getRuntime().runFinalization();
+
+ // Double check all the objects were finalized.
+ int got = count.get();
+ if (n != got) {
+ throw new IllegalStateException(
+ String.format("Only %i of %i objects finalized?", got, n));
+ }
+ }
+}
diff --git a/benchmarks/ReferenceGetBenchmark.java b/benchmarks/ReferenceGetBenchmark.java
new file mode 100644
index 0000000..6ea237b
--- /dev/null
+++ b/benchmarks/ReferenceGetBenchmark.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks;
+
+import com.google.caliper.Param;
+import java.lang.ref.Reference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
+
+public class ReferenceGetBenchmark {
+ @Param boolean intrinsicDisabled;
+
+ private Object obj = "str";
+
+ protected void setUp() throws Exception {
+ Field intrinsicDisabledField = Reference.class.getDeclaredField("disableIntrinsic");
+ intrinsicDisabledField.setAccessible(true);
+ intrinsicDisabledField.setBoolean(null, intrinsicDisabled);
+ }
+
+ public void timeSoftReferenceGet(int reps) throws Exception {
+ Reference soft = new SoftReference(obj);
+ for (int i = 0; i < reps; i++) {
+ Object o = soft.get();
+ }
+ }
+
+ public void timeWeakReferenceGet(int reps) throws Exception {
+ Reference weak = new WeakReference(obj);
+ for (int i = 0; i < reps; i++) {
+ Object o = weak.get();
+ }
+ }
+
+ public void timeNonPreservedWeakReferenceGet(int reps) throws Exception {
+ Reference weak = new WeakReference(obj);
+ obj = null;
+ Runtime.getRuntime().gc();
+ for (int i = 0; i < reps; i++) {
+ Object o = weak.get();
+ }
+ }
+}
diff --git a/benchmarks/SmallBigIntegerBenchmark.java b/benchmarks/SmallBigIntegerBenchmark.java
new file mode 100644
index 0000000..f513bf4
--- /dev/null
+++ b/benchmarks/SmallBigIntegerBenchmark.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.math.BigInteger;
+import java.util.Random;
+
+/**
+ * This measures performance of operations on small BigIntegers.
+ * We manually determine the number of iterations so that it should cause total memory
+ * allocation on the order of a few hundred megabytes. Due to BigInteger's reliance on
+ * finalization, these may unfortunately all be kept around at once.
+ *
+ * This is not structured as a proper benchmark; just run main(), e.g. with
+ * vogar libcore/benchmarks/src/benchmarks/SmallBigIntegerBenchmark.java
+ */
+public class SmallBigIntegerBenchmark {
+ // We allocate about 2 1/3 BigIntegers per iteration.
+ // Assuming 100 bytes/BigInteger, this gives us around 500MB total.
+ static final int NITERS = 2 * 1000 * 1000;
+ static final BigInteger BIG_THREE = BigInteger.valueOf(3);
+ static final BigInteger BIG_FOUR = BigInteger.valueOf(4);
+
+ public static void main(String args[]) {
+ final Random r = new Random();
+ BigInteger x = new BigInteger(20, r);
+ final long startNanos = System.nanoTime();
+ long intermediateNanos = 0;
+ for (int i = 0; i < NITERS; ++i) {
+ if (i == NITERS / 100) {
+ intermediateNanos = System.nanoTime();
+ }
+ // We know this converges, but the compiler doesn't.
+ if (x.and(BigInteger.ONE).equals(BigInteger.ONE)) {
+ x = x.multiply(BIG_THREE).add(BigInteger.ONE);
+ } else {
+ x = x.shiftRight(1);
+ }
+ }
+ if (x.signum() < 0 || x.compareTo(BIG_FOUR) > 0) {
+ throw new AssertionError("Something went horribly wrong.");
+ }
+ final long finalNanos = System.nanoTime();
+ double firstFewTime = ((double) intermediateNanos - (double) startNanos) / (NITERS / 100);
+ double restTime = ((double) finalNanos - (double) intermediateNanos) / (99 * NITERS / 100);
+ System.out.println("First Few: " + firstFewTime
+ + " nanoseconds per iteration (2.33 BigInteger ops/iter)");
+ System.out.println("Remainder: " + restTime + " nanoseconds per iteration");
+ }
+}
+
diff --git a/benchmarks/StringDexCacheBenchmark.java b/benchmarks/StringDexCacheBenchmark.java
new file mode 100644
index 0000000..ce72b4d
--- /dev/null
+++ b/benchmarks/StringDexCacheBenchmark.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * How long does it take to access a string in the dex cache?
+ */
+public class StringDexCacheBenchmark {
+ public int timeStringDexCacheAccess(int reps) {
+ int v = 0;
+ for (int rep = 0; rep < reps; ++rep) {
+ // Deliberately obscured to make optimizations less likely.
+ String s = (rep >= 0) ? "hello, world!" : null;
+ v += s.length();
+ }
+ return v;
+ }
+}
diff --git a/benchmarks/StringIterationBenchmark.java b/benchmarks/StringIterationBenchmark.java
new file mode 100644
index 0000000..1ee9e8c
--- /dev/null
+++ b/benchmarks/StringIterationBenchmark.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+/**
+ * How do the various schemes for iterating through a string compare?
+ */
+public class StringIterationBenchmark {
+ public void timeStringIteration0(int reps) {
+ String s = "hello, world!";
+ for (int rep = 0; rep < reps; ++rep) {
+ char ch;
+ for (int i = 0; i < s.length(); ++i) {
+ ch = s.charAt(i);
+ }
+ }
+ }
+ public void timeStringIteration1(int reps) {
+ String s = "hello, world!";
+ for (int rep = 0; rep < reps; ++rep) {
+ char ch;
+ for (int i = 0, length = s.length(); i < length; ++i) {
+ ch = s.charAt(i);
+ }
+ }
+ }
+ public void timeStringIteration2(int reps) {
+ String s = "hello, world!";
+ for (int rep = 0; rep < reps; ++rep) {
+ char ch;
+ char[] chars = s.toCharArray();
+ for (int i = 0, length = chars.length; i < length; ++i) {
+ ch = chars[i];
+ }
+ }
+ }
+ public void timeStringToCharArray(int reps) {
+ String s = "hello, world!";
+ for (int rep = 0; rep < reps; ++rep) {
+ char[] chars = s.toCharArray();
+ }
+ }
+}
diff --git a/benchmarks/SystemArrayCopyBenchmark.java b/benchmarks/SystemArrayCopyBenchmark.java
new file mode 100644
index 0000000..000b497
--- /dev/null
+++ b/benchmarks/SystemArrayCopyBenchmark.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2013 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import com.google.caliper.Param;
+
+public class SystemArrayCopyBenchmark {
+ @Param({"2", "4", "8", "16", "32", "64", "128", "256", "512", "1024",
+ "2048", "4096", "8192", "16384", "32768", "65536", "131072", "262144"})
+ int arrayLength;
+
+ // Provides benchmarking for different types of arrays using the arraycopy function.
+
+ public void timeSystemCharArrayCopy(int reps) {
+ final int len = arrayLength;
+ char[] src = new char[len];
+ char[] dst = new char[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemByteArrayCopy(int reps) {
+ final int len = arrayLength;
+ byte[] src = new byte[len];
+ byte[] dst = new byte[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemShortArrayCopy(int reps) {
+ final int len = arrayLength;
+ short[] src = new short[len];
+ short[] dst = new short[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemIntArrayCopy(int reps) {
+ final int len = arrayLength;
+ int[] src = new int[len];
+ int[] dst = new int[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemLongArrayCopy(int reps) {
+ final int len = arrayLength;
+ long[] src = new long[len];
+ long[] dst = new long[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemFloatArrayCopy(int reps) {
+ final int len = arrayLength;
+ float[] src = new float[len];
+ float[] dst = new float[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemDoubleArrayCopy(int reps) {
+ final int len = arrayLength;
+ double[] src = new double[len];
+ double[] dst = new double[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+
+ public void timeSystemBooleanArrayCopy(int reps) {
+ final int len = arrayLength;
+ boolean[] src = new boolean[len];
+ boolean[] dst = new boolean[len];
+ for (int rep = 0; rep < reps; ++rep) {
+ System.arraycopy(src, 0, dst, 0, len);
+ }
+ }
+}
diff --git a/benchmarks/VirtualVersusInterfaceBenchmark.java b/benchmarks/VirtualVersusInterfaceBenchmark.java
new file mode 100644
index 0000000..fa3bd6c
--- /dev/null
+++ b/benchmarks/VirtualVersusInterfaceBenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Is there a performance reason to "Prefer virtual over interface", as the
+ * Android documentation once claimed?
+ */
+public class VirtualVersusInterfaceBenchmark {
+ public void timeMapPut(int reps) {
+ Map<String, String> map = new HashMap<String, String>();
+ for (int i = 0; i < reps; ++i) {
+ map.put("hello", "world");
+ }
+ }
+ public void timeHashMapPut(int reps) {
+ HashMap<String, String> map = new HashMap<String, String>();
+ for (int i = 0; i < reps; ++i) {
+ map.put("hello", "world");
+ }
+ }
+}
diff --git a/benchmarks/XmlParseBenchmark.java b/benchmarks/XmlParseBenchmark.java
new file mode 100644
index 0000000..1029616
--- /dev/null
+++ b/benchmarks/XmlParseBenchmark.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.util.Arrays;
+import java.util.List;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xmlpull.v1.XmlPullParser;
+
+public class XmlParseBenchmark {
+
+ @Param String xmlFile;
+ ByteArrayInputStream inputStream;
+
+ static List<String> xmlFileValues = Arrays.asList(
+ "/etc/apns-conf.xml",
+ "/etc/media_profiles.xml",
+ "/etc/permissions/features.xml"
+ );
+
+ private SAXParser saxParser;
+ private DocumentBuilder documentBuilder;
+ private Constructor<? extends XmlPullParser> kxmlConstructor;
+ private Constructor<? extends XmlPullParser> expatConstructor;
+
+ @SuppressWarnings("unchecked")
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ byte[] xmlBytes = getXmlBytes();
+ inputStream = new ByteArrayInputStream(xmlBytes);
+ inputStream.mark(xmlBytes.length);
+
+ SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
+ saxParser = saxParserFactory.newSAXParser();
+
+ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilder = builderFactory.newDocumentBuilder();
+
+ kxmlConstructor = (Constructor) Class.forName("com.android.org.kxml2.io.KXmlParser")
+ .getConstructor();
+ expatConstructor = (Constructor) Class.forName("org.apache.harmony.xml.ExpatPullParser")
+ .getConstructor();
+ }
+
+ private byte[] getXmlBytes() throws IOException {
+ FileInputStream fileIn = new FileInputStream(xmlFile);
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ int count;
+ byte[] buffer = new byte[1024];
+ while ((count = fileIn.read(buffer)) != -1) {
+ bytesOut.write(buffer, 0, count);
+ }
+ fileIn.close();
+ return bytesOut.toByteArray();
+ }
+
+ public int timeSax(int reps) throws IOException, SAXException {
+ int elementCount = 0;
+ for (int i = 0; i < reps; i++) {
+ inputStream.reset();
+ ElementCounterSaxHandler elementCounterSaxHandler = new ElementCounterSaxHandler();
+ saxParser.parse(inputStream, elementCounterSaxHandler);
+ elementCount += elementCounterSaxHandler.elementCount;
+ }
+ return elementCount;
+ }
+
+ private static class ElementCounterSaxHandler extends DefaultHandler {
+ int elementCount = 0;
+ @Override public void startElement(String uri, String localName,
+ String qName, Attributes attributes) {
+ elementCount++;
+ }
+ }
+
+ public int timeDom(int reps) throws IOException, SAXException {
+ int elementCount = 0;
+ for (int i = 0; i < reps; i++) {
+ inputStream.reset();
+ Document document = documentBuilder.parse(inputStream);
+ elementCount += countDomElements(document.getDocumentElement());
+ }
+ return elementCount;
+ }
+
+ private int countDomElements(Node node) {
+ int result = 0;
+ for (; node != null; node = node.getNextSibling()) {
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ result++;
+ }
+ result += countDomElements(node.getFirstChild());
+ }
+ return result;
+ }
+
+ public int timeExpat(int reps) throws Exception {
+ return testXmlPull(expatConstructor, reps);
+ }
+
+ public int timeKxml(int reps) throws Exception {
+ return testXmlPull(kxmlConstructor, reps);
+ }
+
+ private int testXmlPull(Constructor<? extends XmlPullParser> constructor, int reps)
+ throws Exception {
+ int elementCount = 0;
+ for (int i = 0; i < reps; i++) {
+ inputStream.reset();
+ XmlPullParser xmlPullParser = constructor.newInstance();
+ xmlPullParser.setInput(inputStream, "UTF-8");
+ int type;
+ while ((type = xmlPullParser.next()) != XmlPullParser.END_DOCUMENT) {
+ if (type == XmlPullParser.START_TAG) {
+ elementCount++;
+ }
+ }
+ }
+ return elementCount;
+ }
+}
diff --git a/benchmarks/XmlSerializeBenchmark.java b/benchmarks/XmlSerializeBenchmark.java
new file mode 100644
index 0000000..a8c51b3
--- /dev/null
+++ b/benchmarks/XmlSerializeBenchmark.java
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.CharArrayWriter;
+import java.lang.reflect.Constructor;
+import java.util.Random;
+import org.xmlpull.v1.XmlSerializer;
+
+
+public class XmlSerializeBenchmark {
+
+ @Param( {"0.99 0.7 0.7 0.7 0.7 0.7",
+ "0.999 0.3 0.3 0.95 0.9 0.9"})
+ String datasetAsString;
+
+ @Param( { "854328", "312547"} )
+ int seed;
+
+ double[] dataset;
+ private Constructor<? extends XmlSerializer> kxmlConstructor;
+ private Constructor<? extends XmlSerializer> fastConstructor;
+
+ private void serializeRandomXml(Constructor<? extends XmlSerializer> ctor, long seed)
+ throws Exception {
+ double contChance = dataset[0];
+ double levelUpChance = dataset[1];
+ double levelDownChance = dataset[2];
+ double attributeChance = dataset[3];
+ double writeChance1 = dataset[4];
+ double writeChance2 = dataset[5];
+
+ XmlSerializer serializer = (XmlSerializer) ctor.newInstance();
+
+ CharArrayWriter w = new CharArrayWriter();
+ serializer.setOutput(w);
+ int level = 0;
+ Random r = new Random(seed);
+ char[] toWrite = {'a','b','c','d','s','z'};
+ serializer.startDocument("UTF-8", true);
+ while(r.nextDouble() < contChance) {
+ while(level > 0 && r.nextDouble() < levelUpChance) {
+ serializer.endTag("aaaaaa", "bbbbbb");
+ level--;
+ }
+ while(r.nextDouble() < levelDownChance) {
+ serializer.startTag("aaaaaa", "bbbbbb");
+ level++;
+ }
+ serializer.startTag("aaaaaa", "bbbbbb");
+ level++;
+ while(r.nextDouble() < attributeChance) {
+ serializer.attribute("aaaaaa", "cccccc", "dddddd");
+ }
+ serializer.endTag("aaaaaa", "bbbbbb");
+ level--;
+ while(r.nextDouble() < writeChance1)
+ serializer.text(toWrite, 0, 5);
+ while(r.nextDouble() < writeChance2)
+ serializer.text("Textxtsxtxtxt ");
+ }
+ serializer.endDocument();
+ }
+
+ @SuppressWarnings("unchecked")
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ kxmlConstructor = (Constructor) Class.forName("com.android.org.kxml2.io.KXmlSerializer")
+ .getConstructor();
+ fastConstructor = (Constructor) Class.forName("com.android.internal.util.FastXmlSerializer")
+ .getConstructor();
+ String[] splitted = datasetAsString.split(" ");
+ dataset = new double[splitted.length];
+ for (int i = 0; i < splitted.length; i++) {
+ dataset[i] = Double.parseDouble(splitted[i]);
+ }
+ }
+
+ private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor, int reps)
+ throws Exception {
+ for (int i = 0; i < reps; i++) {
+ serializeRandomXml(ctor, seed);
+ }
+ }
+
+ public void timeKxml(int reps) throws Exception {
+ internalTimeSerializer(kxmlConstructor, reps);
+ }
+
+ public void timeFast(int reps) throws Exception {
+ internalTimeSerializer(fastConstructor, reps);
+ }
+}
diff --git a/benchmarks/ZipFileBenchmark.java b/benchmarks/ZipFileBenchmark.java
new file mode 100644
index 0000000..78557e0
--- /dev/null
+++ b/benchmarks/ZipFileBenchmark.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Random;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+
+public class ZipFileBenchmark {
+
+ private File file;
+ @Param({"128", "1024", "8192"}) int numEntries;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ System.setProperty("java.io.tmpdir", "/data/local/tmp");
+ file = File.createTempFile(getClass().getName(), ".zip");
+ file.deleteOnExit();
+ writeEntries(new ZipOutputStream(new FileOutputStream(file)), numEntries, 0);
+ ZipFile zipFile = new ZipFile(file);
+ for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); ) {
+ ZipEntry zipEntry = e.nextElement();
+ }
+ zipFile.close();
+ }
+
+ public void timeZipFileOpen(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ ZipFile zf = new ZipFile(file);
+ }
+ }
+
+ /**
+ * Compresses the given number of files, each of the given size, into a .zip archive.
+ */
+ protected void writeEntries(ZipOutputStream out, int entryCount, long entrySize)
+ throws IOException {
+ byte[] writeBuffer = new byte[8192];
+ Random random = new Random();
+ try {
+ for (int entry = 0; entry < entryCount; ++entry) {
+ ZipEntry ze = new ZipEntry(Integer.toHexString(entry));
+ ze.setSize(entrySize);
+ out.putNextEntry(ze);
+
+ for (long i = 0; i < entrySize; i += writeBuffer.length) {
+ random.nextBytes(writeBuffer);
+ int byteCount = (int) Math.min(writeBuffer.length, entrySize - i);
+ out.write(writeBuffer, 0, byteCount);
+ }
+
+ out.closeEntry();
+ }
+ } finally {
+ out.close();
+ }
+ }
+}
diff --git a/benchmarks/ZipFileReadBenchmark.java b/benchmarks/ZipFileReadBenchmark.java
new file mode 100644
index 0000000..f6125a6
--- /dev/null
+++ b/benchmarks/ZipFileReadBenchmark.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.File;
+import java.io.InputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Random;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipOutputStream;
+
+
+public class ZipFileReadBenchmark {
+ private File file;
+ @Param({"1024", "16384", "65536"}) int readBufferSize;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ System.setProperty("java.io.tmpdir", "/data/local/tmp");
+ file = File.createTempFile(getClass().getName(), ".zip");
+ writeEntries(new ZipOutputStream(new FileOutputStream(file)), 2, 1024*1024);
+ ZipFile zipFile = new ZipFile(file);
+ for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); ) {
+ ZipEntry zipEntry = e.nextElement();
+ }
+ zipFile.close();
+ }
+
+ /**
+ * Compresses the given number of files, each of the given size, into a .zip archive.
+ */
+ protected void writeEntries(ZipOutputStream out, int entryCount, long entrySize)
+ throws IOException {
+ byte[] writeBuffer = new byte[8192];
+ Random random = new Random();
+ try {
+ for (int entry = 0; entry < entryCount; ++entry) {
+ ZipEntry ze = new ZipEntry(Integer.toHexString(entry));
+ ze.setSize(entrySize);
+ out.putNextEntry(ze);
+
+ for (long i = 0; i < entrySize; i += writeBuffer.length) {
+ random.nextBytes(writeBuffer);
+ int byteCount = (int) Math.min(writeBuffer.length, entrySize - i);
+ out.write(writeBuffer, 0, byteCount);
+ }
+
+ out.closeEntry();
+ }
+ } finally {
+ out.close();
+ }
+ }
+
+ public void timeZipFileRead(int reps) throws Exception {
+ byte readBuffer[] = new byte[readBufferSize];
+ for (int i = 0; i < reps; ++i) {
+ ZipFile zipFile = new ZipFile(file);
+ for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements(); ) {
+ ZipEntry zipEntry = e.nextElement();
+ InputStream is = zipFile.getInputStream(zipEntry);
+ while (true) {
+ if (is.read(readBuffer, 0, readBuffer.length) < 0) {
+ break;
+ }
+ }
+ }
+ zipFile.close();
+ }
+ }
+}
diff --git a/benchmarks/regression/AnnotatedElementBenchmark.java b/benchmarks/regression/AnnotatedElementBenchmark.java
new file mode 100644
index 0000000..dd7da4c
--- /dev/null
+++ b/benchmarks/regression/AnnotatedElementBenchmark.java
@@ -0,0 +1,260 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class AnnotatedElementBenchmark {
+
+ private Class<?> type;
+ private Field field;
+ private Method method;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ type = Type.class;
+ field = Type.class.getField("field");
+ method = Type.class.getMethod("method", String.class);
+ }
+
+
+ // get annotations by member type and method
+
+ public void timeGetTypeAnnotations(int reps) {
+ for (int i = 0; i < reps; i++) {
+ type.getAnnotations();
+ }
+ }
+
+ public void timeGetFieldAnnotations(int reps) {
+ for (int i = 0; i < reps; i++) {
+ field.getAnnotations();
+ }
+ }
+
+ public void timeGetMethodAnnotations(int reps) {
+ for (int i = 0; i < reps; i++) {
+ method.getAnnotations();
+ }
+ }
+
+ public void timeGetParameterAnnotations(int reps) {
+ for (int i = 0; i < reps; i++) {
+ method.getParameterAnnotations();
+ }
+ }
+
+ public void timeGetTypeAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ type.getAnnotation(Marker.class);
+ }
+ }
+
+ public void timeGetFieldAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ field.getAnnotation(Marker.class);
+ }
+ }
+
+ public void timeGetMethodAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ method.getAnnotation(Marker.class);
+ }
+ }
+
+ public void timeIsTypeAnnotationPresent(int reps) {
+ for (int i = 0; i < reps; i++) {
+ type.isAnnotationPresent(Marker.class);
+ }
+ }
+
+ public void timeIsFieldAnnotationPresent(int reps) {
+ for (int i = 0; i < reps; i++) {
+ field.isAnnotationPresent(Marker.class);
+ }
+ }
+
+ public void timeIsMethodAnnotationPresent(int reps) {
+ for (int i = 0; i < reps; i++) {
+ method.isAnnotationPresent(Marker.class);
+ }
+ }
+
+ // get annotations by result size
+
+ public void timeGetAllReturnsLargeAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasLargeAnnotation.class.getAnnotations();
+ }
+ }
+
+ public void timeGetAllReturnsSmallAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasSmallAnnotation.class.getAnnotations();
+ }
+ }
+
+ public void timeGetAllReturnsMarkerAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasMarkerAnnotation.class.getAnnotations();
+ }
+ }
+
+ public void timeGetAllReturnsNoAnnotation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasNoAnnotations.class.getAnnotations();
+ }
+ }
+
+ public void timeGetAllReturnsThreeAnnotations(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasThreeAnnotations.class.getAnnotations();
+ }
+ }
+
+
+ // get annotations with inheritance
+
+ public void timeGetAnnotationsOnSubclass(int reps) {
+ for (int i = 0; i < reps; i++) {
+ ExtendsHasThreeAnnotations.class.getAnnotations();
+ }
+ }
+
+ public void timeGetDeclaredAnnotationsOnSubclass(int reps) {
+ for (int i = 0; i < reps; i++) {
+ ExtendsHasThreeAnnotations.class.getDeclaredAnnotations();
+ }
+ }
+
+
+ // get annotations with enclosing / inner classes
+
+ public void timeGetDeclaredClasses(int reps) {
+ for (int i = 0; i < reps; i++) {
+ AnnotatedElementBenchmark.class.getDeclaredClasses();
+ }
+ }
+
+ public void timeGetDeclaringClass(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasSmallAnnotation.class.getDeclaringClass();
+ }
+ }
+
+ public void timeGetEnclosingClass(int reps) {
+ Object anonymousClass = new Object() {};
+ for (int i = 0; i < reps; i++) {
+ anonymousClass.getClass().getEnclosingClass();
+ }
+ }
+
+ public void timeGetEnclosingConstructor(int reps) {
+ Object anonymousClass = new Object() {};
+ for (int i = 0; i < reps; i++) {
+ anonymousClass.getClass().getEnclosingConstructor();
+ }
+ }
+
+ public void timeGetEnclosingMethod(int reps) {
+ Object anonymousClass = new Object() {};
+ for (int i = 0; i < reps; i++) {
+ anonymousClass.getClass().getEnclosingMethod();
+ }
+ }
+
+ public void timeGetModifiers(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasSmallAnnotation.class.getModifiers();
+ }
+ }
+
+ public void timeGetSimpleName(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasSmallAnnotation.class.getSimpleName();
+ }
+ }
+
+ public void timeIsAnonymousClass(int reps) {
+ Object anonymousClass = new Object() {};
+ for (int i = 0; i < reps; i++) {
+ anonymousClass.getClass().isAnonymousClass();
+ }
+ }
+
+ public void timeIsLocalClass(int reps) {
+ for (int i = 0; i < reps; i++) {
+ HasSmallAnnotation.class.isLocalClass();
+ }
+ }
+
+
+ // the annotated elements
+
+ @Marker
+ public class Type {
+ @Marker public String field;
+ @Marker public void method(@Marker String parameter) {}
+ }
+
+ @Large(a = "on class", b = {"A", "B", "C" },
+ c = @Small(e="E1", f=1695938256, g=7264081114510713000L),
+ d = { @Small(e="E2", f=1695938256, g=7264081114510713000L) })
+ public class HasLargeAnnotation {}
+
+ @Small(e="E1", f=1695938256, g=7264081114510713000L)
+ public class HasSmallAnnotation {}
+
+ @Marker
+ public class HasMarkerAnnotation {}
+
+ public class HasNoAnnotations {}
+
+ @Large(a = "on class", b = {"A", "B", "C" },
+ c = @Small(e="E1", f=1695938256, g=7264081114510713000L),
+ d = { @Small(e="E2", f=1695938256, g=7264081114510713000L) })
+ @Small(e="E1", f=1695938256, g=7264081114510713000L)
+ @Marker
+ public class HasThreeAnnotations {}
+
+ public class ExtendsHasThreeAnnotations extends HasThreeAnnotations {}
+
+
+ // the annotations
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Marker {}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Large {
+ String a() default "";
+ String[] b() default {};
+ Small c() default @Small;
+ Small[] d() default {};
+ }
+
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Small {
+ String e() default "";
+ int f() default 0;
+ long g() default 0L;
+ }
+}
diff --git a/benchmarks/regression/BidiBenchmark.java b/benchmarks/regression/BidiBenchmark.java
new file mode 100644
index 0000000..a4e47e1
--- /dev/null
+++ b/benchmarks/regression/BidiBenchmark.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.math.BigDecimal;
+import java.text.AttributedCharacterIterator;
+import java.text.Bidi;
+import java.text.DecimalFormat;
+
+public class BidiBenchmark {
+
+ private static final AttributedCharacterIterator charIter =
+ DecimalFormat.getInstance().formatToCharacterIterator(new BigDecimal(Math.PI));
+
+ public void time_createBidiFromIter(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi bidi = new Bidi(charIter);
+ }
+ }
+
+ public void time_createBidiFromCharArray(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi bd = new Bidi(new char[]{'s', 's', 's'}, 0, new byte[]{(byte) 1,
+ (byte) 2, (byte) 3}, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
+ }
+ }
+
+ public void time_createBidiFromString(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi bidi = new Bidi("Hello", Bidi.DIRECTION_LEFT_TO_RIGHT);
+ }
+ }
+
+ public void time_reorderVisually(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi.reorderVisually(new byte[]{2, 1, 3, 0, 4}, 0,
+ new String[]{"H", "e", "l", "l", "o"}, 0, 5);
+ }
+ }
+
+ public void time_hebrewBidi(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi bd = new Bidi(new char[]{'\u05D0', '\u05D0', '\u05D0'}, 0,
+ new byte[]{(byte) -1, (byte) -2, (byte) -3}, 0, 3,
+ Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+ bd = new Bidi(new char[]{'\u05D0', '\u05D0', '\u05D0'}, 0,
+ new byte[]{(byte) -1, (byte) -2, (byte) -3}, 0, 3,
+ Bidi.DIRECTION_LEFT_TO_RIGHT);
+ }
+ }
+
+ public void time_complicatedOverrideBidi(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a".toCharArray(), 0,
+ new byte[]{0, 0, 0, -3, -3, 2, 2, 0, 3}, 0, 9,
+ Bidi.DIRECTION_RIGHT_TO_LEFT);
+ }
+ }
+
+ public void time_requiresBidi(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Bidi.requiresBidi("\u05D0".toCharArray(), 1, 1); // false.
+ Bidi.requiresBidi("\u05D0".toCharArray(), 0, 1); // true.
+ }
+ }
+
+}
diff --git a/benchmarks/regression/BigIntegerBenchmark.java b/benchmarks/regression/BigIntegerBenchmark.java
new file mode 100644
index 0000000..b890aa1
--- /dev/null
+++ b/benchmarks/regression/BigIntegerBenchmark.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.math.BigInteger;
+import java.util.Random;
+
+public class BigIntegerBenchmark {
+ public void timeRandomDivision(int reps) throws Exception {
+ Random r = new Random();
+ BigInteger x = new BigInteger(1024, r);
+ BigInteger y = new BigInteger(1024, r);
+ for (int i = 0; i < reps; ++i) {
+ x.divide(y);
+ }
+ }
+
+ public void timeRandomGcd(int reps) throws Exception {
+ Random r = new Random();
+ BigInteger x = new BigInteger(1024, r);
+ BigInteger y = new BigInteger(1024, r);
+ for (int i = 0; i < reps; ++i) {
+ x.gcd(y);
+ }
+ }
+
+ public void timeRandomMultiplication(int reps) throws Exception {
+ Random r = new Random();
+ BigInteger x = new BigInteger(1024, r);
+ BigInteger y = new BigInteger(1024, r);
+ for (int i = 0; i < reps; ++i) {
+ x.multiply(y);
+ }
+ }
+}
diff --git a/benchmarks/regression/BitSetBenchmark.java b/benchmarks/regression/BitSetBenchmark.java
new file mode 100644
index 0000000..92ef8f1
--- /dev/null
+++ b/benchmarks/regression/BitSetBenchmark.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.util.BitSet;
+
+public class BitSetBenchmark {
+ @Param({ "1000", "10000" })
+ private int size;
+
+ private BitSet bs;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ bs = new BitSet(size);
+ }
+
+ public void timeIsEmptyTrue(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ if (!bs.isEmpty()) throw new RuntimeException();
+ }
+ }
+
+ public void timeIsEmptyFalse(int reps) {
+ bs.set(bs.size() - 1);
+ for (int i = 0; i < reps; ++i) {
+ if (bs.isEmpty()) throw new RuntimeException();
+ }
+ }
+
+ public void timeGet(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ bs.get(i % size);
+ }
+ }
+
+ public void timeClear(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ bs.clear(i % size);
+ }
+ }
+
+ public void timeSet(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ bs.set(i % size);
+ }
+ }
+
+ public void timeSetOn(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ bs.set(i % size, true);
+ }
+ }
+
+ public void timeSetOff(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ bs.set(i % size, false);
+ }
+ }
+}
diff --git a/benchmarks/regression/BreakIteratorBenchmark.java b/benchmarks/regression/BreakIteratorBenchmark.java
new file mode 100644
index 0000000..804b7e3
--- /dev/null
+++ b/benchmarks/regression/BreakIteratorBenchmark.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.text.BreakIterator;
+import java.util.Locale;
+
+public final class BreakIteratorBenchmark {
+
+ public static enum Text {
+ LIPSUM(Locale.US, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mollis consequat nisl non pharetra. Praesent pretium vehicula odio sed ultrices. Aenean a felis libero. Vivamus sed commodo nibh. Pellentesque turpis lectus, euismod vel ante nec, cursus posuere orci. Suspendisse velit neque, fermentum luctus ultrices in, ultrices vitae arcu. Duis tincidunt cursus lorem. Nam ultricies accumsan quam vitae imperdiet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Quisque aliquet pretium nisi, eget laoreet enim molestie sit amet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.\nNam dapibus aliquam lacus ac suscipit. Proin in nibh sit amet purus congue laoreet eget quis nisl. Morbi gravida dignissim justo, a venenatis ante pulvinar at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ultrices vestibulum dui, vel aliquam lacus aliquam quis. Duis fringilla sapien ac lacus egestas, vel adipiscing elit euismod. Donec non tellus odio. Donec gravida eu massa ac feugiat. Aliquam erat volutpat. Praesent id adipiscing metus, nec laoreet enim. Aliquam vitae posuere turpis. Mauris ac pharetra sem. In at placerat tortor. Vivamus ac vehicula neque. Cras volutpat ullamcorper massa et varius. Praesent sagittis neque vitae nulla euismod pharetra.\nSed placerat sapien non molestie sollicitudin. Nullam sit amet dictum quam. Etiam tincidunt tortor vel pretium vehicula. Praesent fringilla ipsum vel velit luctus dignissim. Nulla massa ligula, mattis in enim et, mattis lacinia odio. Suspendisse tristique urna a orci commodo tempor. Duis lacinia egestas arcu a sollicitudin.\nIn ac feugiat lacus. Nunc fermentum eu est at tristique. Pellentesque quis ligula et orci placerat lacinia. Maecenas quis mauris diam. Etiam mi ipsum, tempus in purus quis, euismod faucibus orci. Nulla facilisi. Praesent sit amet sapien vel elit porta adipiscing. Phasellus sit amet volutpat diam.\nProin bibendum elit non lacus pharetra, quis eleifend tellus placerat. Nulla facilisi. Maecenas ante diam, pellentesque mattis mattis in, porta ut lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc interdum tristique metus, in scelerisque odio fermentum eget. Cras nec venenatis lacus. Aenean euismod eget metus quis molestie. Cras tincidunt dolor ut massa ornare, in elementum lacus auctor. Cras sodales nisl lacus, id ultrices ligula varius at. Sed tristique sit amet tellus vel mollis. Sed sed sollicitudin quam. Sed sed adipiscing risus, et dictum orci. Cras tempor pellentesque turpis et tempus."),
+ LONGPARA(Locale.US, "During dinner, Mr. Bennet scarcely spoke at all; but when the servants were withdrawn, he thought it time to have some conversation with his guest, and therefore started a subject in which he expected him to shine, by observing that he seemed very fortunate in his patroness. Lady Catherine de Bourgh's attention to his wishes, and consideration for his comfort, appeared very remarkable. Mr. Bennet could not have chosen better. Mr. Collins was eloquent in her praise. The subject elevated him to more than usual solemnity of manner, and with a most important aspect he protested that \"he had never in his life witnessed such behaviour in a person of rank--such affability and condescension, as he had himself experienced from Lady Catherine. She had been graciously pleased to approve of both of the discourses which he had already had the honour of preaching before her. She had also asked him twice to dine at Rosings, and had sent for him only the Saturday before, to make up her pool of quadrille in the evening. Lady Catherine was reckoned proud by many people he knew, but _he_ had never seen anything but affability in her. She had always spoken to him as she would to any other gentleman; she made not the smallest objection to his joining in the society of the neighbourhood nor to his leaving the parish occasionally for a week or two, to visit his relations. She had even condescended to advise him to marry as soon as he could, provided he chose with discretion; and had once paid him a visit in his humble parsonage, where she had perfectly approved all the alterations he had been making, and had even vouchsafed to suggest some herself--some shelves in the closet up stairs.\""),
+ GERMAN(Locale.GERMANY, "Aber dieser Freiheit setzte endlich der Winter ein Ziel. Draußen auf den Feldern und den hohen Bergen lag der Schnee und Peter wäre in seinem dünnen Leinwandjäckchen bald erfroren. Es war also seine einzige Freude, hinaus vor die Hütte zu treten und den Sperlingen Brotkrümchen zu streuen, was er sich jedesmal an seinem Frühstück absparte. Wenn nun die Vögel so lustig zwitscherten und um ihn herumflogen, da klopfte ihm das Herz vor Lust, und oft gab er ihnen sein ganzes Stück Schwarzbrot, ohne daran zu denken, daß er dafür alsdann selbst hungern müsse."),
+ THAI(Locale.forLanguageTag("th-TH"), "เป็นสำเนียงทางการของภาษาไทย เดิมทีเป็นการผสมผสานกันระหว่างสำเนียงอยุธยาและชาวไทยเชื้อสายจีนรุ่นหลังที่พูดไทยแทนกลุ่มภาษาจีน ลักษณะเด่นคือมีการออกเสียงที่ชัดเจนและแข็งกระด้างซึ่งได้รับอิทธิพลจากภาษาแต้จิ๋ว การออกเสียงพยัญชนะ สระ การผันวรรณยุกต์ที่ในภาษาไทยมาตรฐาน มาจากสำเนียงถิ่นนี้ในขณะที่ภาษาไทยสำเนียงอื่นล้วนเหน่อทั้งสิ้น คำศัพท์ที่ใช้ในสำเนียงกรุงเทพจำนวนมากได้รับมาจากกลุ่มภาษาจีนเช่นคำว่า โป๊, เฮ็ง, อาหมวย, อาซิ่ม ซึ่งมาจากภาษาแต้จิ๋ว และจากภาษาจีนเช่น ถู(涂), ชิ่ว(去 อ่านว่า\"ชู่\") และคำว่า ทาย(猜 อ่านว่า \"ชาย\") เป็นต้น เนื่องจากสำเนียงกรุงเทพได้รับอิทธิพลมาจากภาษาจีนดังนั้นตัวอักษร \"ร\" มักออกเสียงเหมารวมเป็น \"ล\" หรือคำควบกล่ำบางคำถูกละทิ้งไปด้วยเช่น รู้ เป็น ลู้, เรื่อง เป็น เลื่อง หรือ ประเทศ เป็น ปะเทศ เป็นต้นสร้างความลำบากให้แก่ต่างชาติที่ต้องการเรียนภาษาไทย แต่อย่างไรก็ตามผู้ที่พูดสำเนียงถิ่นนี้ก็สามารถออกอักขระภาษาไทยตามมาตรฐานได้อย่างถูกต้องเพียงแต่มักเผลอไม่ค่อยออกเสียง"),
+ THAI2(Locale.forLanguageTag("th-TH"), "this is the word browser in Thai: เบราว์เซอร์"),
+ TABS(Locale.US, "one\t\t\t\t\t\t\t\t\t\t\t\t\t\ttwo\n"),
+ ACCENT(Locale.US, "e\u0301\u00e9\nwhich is:\n\"e\\u0301\\u00e9\""),
+ EMOJI(Locale.US, ">>\ud83d\ude01<<\nwhich is:\n\">>\\ud83d\\ude01<<\""),
+ SPACES(Locale.US, " leading spaces and trailing ones too "),
+ EMPTY(Locale.US, ""),
+ NEWLINE(Locale.US, "\\n:\n"),
+ BIDI(Locale.forLanguageTag("he-IL"), "Sarah שרה is spelled sin ש resh ר heh ה from right to left.");
+
+ final Locale locale;
+ final String text;
+
+ Text(Locale locale, String text) {
+ this.text = text;
+ this.locale = locale;
+ }
+ }
+
+ @Param private Text text;
+
+ public void timeBreakIterator(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ BreakIterator it = BreakIterator.getLineInstance(text.locale);
+ it.setText(text.text);
+
+ while (it.next() != BreakIterator.DONE) {
+ }
+ }
+ }
+
+ public void timeIcuBreakIterator(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ android.icu.text.BreakIterator it =
+ android.icu.text.BreakIterator.getLineInstance(text.locale);
+ it.setText(text.text);
+
+ while (it.next() != android.icu.text.BreakIterator.DONE) {
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/ByteBufferBenchmark.java b/benchmarks/regression/ByteBufferBenchmark.java
new file mode 100644
index 0000000..4febc0a
--- /dev/null
+++ b/benchmarks/regression/ByteBufferBenchmark.java
@@ -0,0 +1,415 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
+import java.nio.channels.FileChannel;
+
+public class ByteBufferBenchmark {
+ public enum MyByteOrder {
+ BIG(ByteOrder.BIG_ENDIAN), LITTLE(ByteOrder.LITTLE_ENDIAN);
+ final ByteOrder byteOrder;
+ MyByteOrder(ByteOrder byteOrder) {
+ this.byteOrder = byteOrder;
+ }
+ }
+
+ @Param private MyByteOrder byteOrder;
+
+ @Param({"true", "false"}) private boolean aligned;
+
+ enum MyBufferType {
+ DIRECT, HEAP, MAPPED;
+ }
+ @Param private MyBufferType bufferType;
+
+ public static ByteBuffer newBuffer(MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws IOException {
+ int size = aligned ? 8192 : 8192 + 8 + 1;
+ ByteBuffer result = null;
+ switch (bufferType) {
+ case DIRECT:
+ result = ByteBuffer.allocateDirect(size);
+ break;
+ case HEAP:
+ result = ByteBuffer.allocate(size);
+ break;
+ case MAPPED:
+ File tmpFile = new File("/sdcard/bm.tmp");
+ if (new File("/tmp").isDirectory()) {
+ // We're running on the desktop.
+ tmpFile = File.createTempFile("MappedByteBufferTest", ".tmp");
+ }
+ tmpFile.createNewFile();
+ tmpFile.deleteOnExit();
+ RandomAccessFile raf = new RandomAccessFile(tmpFile, "rw");
+ raf.setLength(8192*8);
+ FileChannel fc = raf.getChannel();
+ result = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
+ break;
+ }
+ result.order(byteOrder.byteOrder);
+ result.position(aligned ? 0 : 1);
+ return result;
+ }
+
+ //
+ // peeking
+ //
+
+ public void timeByteBuffer_getByte(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.get();
+ }
+ }
+ }
+
+ public void timeByteBuffer_getByteArray(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ byte[] dst = new byte[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(aligned ? 0 : 1);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getByte_indexed(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.get(i);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getChar(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getChar();
+ }
+ }
+ }
+
+ public void timeCharBuffer_getCharArray(int reps) throws Exception {
+ CharBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asCharBuffer();
+ char[] dst = new char[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getChar_indexed(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getChar(i * 2);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getDouble(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getDouble();
+ }
+ }
+ }
+
+ public void timeDoubleBuffer_getDoubleArray(int reps) throws Exception {
+ DoubleBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer();
+ double[] dst = new double[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getFloat(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getFloat();
+ }
+ }
+ }
+
+ public void timeFloatBuffer_getFloatArray(int reps) throws Exception {
+ FloatBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer();
+ float[] dst = new float[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getInt(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getInt();
+ }
+ }
+ }
+
+ public void timeIntBuffer_getIntArray(int reps) throws Exception {
+ IntBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asIntBuffer();
+ int[] dst = new int[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getLong(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getLong();
+ }
+ }
+ }
+
+ public void timeLongBuffer_getLongArray(int reps) throws Exception {
+ LongBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asLongBuffer();
+ long[] dst = new long[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ public void timeByteBuffer_getShort(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.getShort();
+ }
+ }
+ }
+
+ public void timeShortBuffer_getShortArray(int reps) throws Exception {
+ ShortBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asShortBuffer();
+ short[] dst = new short[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ src.position(0);
+ src.get(dst);
+ }
+ }
+ }
+
+ //
+ // poking
+ //
+
+ public void timeByteBuffer_putByte(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(0);
+ for (int i = 0; i < 1024; ++i) {
+ src.put((byte) 0);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putByteArray(int reps) throws Exception {
+ ByteBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ byte[] src = new byte[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(aligned ? 0 : 1);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putChar(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putChar(' ');
+ }
+ }
+ }
+
+ public void timeCharBuffer_putCharArray(int reps) throws Exception {
+ CharBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asCharBuffer();
+ char[] src = new char[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putDouble(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putDouble(0.0);
+ }
+ }
+ }
+
+ public void timeDoubleBuffer_putDoubleArray(int reps) throws Exception {
+ DoubleBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer();
+ double[] src = new double[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putFloat(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putFloat(0.0f);
+ }
+ }
+ }
+
+ public void timeFloatBuffer_putFloatArray(int reps) throws Exception {
+ FloatBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer();
+ float[] src = new float[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putInt(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putInt(0);
+ }
+ }
+ }
+
+ public void timeIntBuffer_putIntArray(int reps) throws Exception {
+ IntBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asIntBuffer();
+ int[] src = new int[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putLong(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putLong(0L);
+ }
+ }
+ }
+
+ public void timeLongBuffer_putLongArray(int reps) throws Exception {
+ LongBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asLongBuffer();
+ long[] src = new long[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+ public void timeByteBuffer_putShort(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ for (int i = 0; i < 1024; ++i) {
+ src.putShort((short) 0);
+ }
+ }
+ }
+
+ public void timeShortBuffer_putShortArray(int reps) throws Exception {
+ ShortBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType).asShortBuffer();
+ short[] src = new short[1024];
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < 1024; ++i) {
+ dst.position(0);
+ dst.put(src);
+ }
+ }
+ }
+
+/*
+ public void time_new_byteArray(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ byte[] bs = new byte[8192];
+ }
+ }
+
+ public void time_ByteBuffer_allocate(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ ByteBuffer bs = ByteBuffer.allocate(8192);
+ }
+ }
+ */
+}
diff --git a/benchmarks/regression/ByteBufferBulkBenchmark.java b/benchmarks/regression/ByteBufferBulkBenchmark.java
new file mode 100644
index 0000000..72078f3
--- /dev/null
+++ b/benchmarks/regression/ByteBufferBulkBenchmark.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.CharBuffer;
+import java.nio.DoubleBuffer;
+import java.nio.FloatBuffer;
+import java.nio.IntBuffer;
+import java.nio.LongBuffer;
+import java.nio.ShortBuffer;
+import java.nio.channels.FileChannel;
+
+public class ByteBufferBulkBenchmark {
+ @Param({"true", "false"}) private boolean aligned;
+
+
+ enum MyBufferType {
+ DIRECT, HEAP, MAPPED
+ }
+ @Param private MyBufferType srcBufferType;
+ @Param private MyBufferType dataBufferType;
+
+ @Param({"4096", "1232896"}) private int bufferSize;
+
+ public static ByteBuffer newBuffer(boolean aligned, MyBufferType bufferType, int bsize) throws IOException {
+ int size = aligned ? bsize : bsize + 8 + 1;
+ ByteBuffer result = null;
+ switch (bufferType) {
+ case DIRECT:
+ result = ByteBuffer.allocateDirect(size);
+ break;
+ case HEAP:
+ result = ByteBuffer.allocate(size);
+ break;
+ case MAPPED:
+ File tmpFile = File.createTempFile("MappedByteBufferTest", ".tmp");
+ tmpFile.createNewFile();
+ tmpFile.deleteOnExit();
+ RandomAccessFile raf = new RandomAccessFile(tmpFile, "rw");
+ raf.setLength(size);
+ FileChannel fc = raf.getChannel();
+ result = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
+ break;
+ }
+ result.position(aligned ? 0 : 1);
+ return result;
+ }
+
+ public void timeByteBuffer_putByteBuffer(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBulkBenchmark.newBuffer(aligned, srcBufferType, bufferSize);
+ ByteBuffer data = ByteBufferBulkBenchmark.newBuffer(aligned, dataBufferType, bufferSize);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ data.position(aligned ? 0 : 1 );
+ src.put(data);
+ }
+ }
+
+}
diff --git a/benchmarks/regression/ByteBufferScalarVersusVectorBenchmark.java b/benchmarks/regression/ByteBufferScalarVersusVectorBenchmark.java
new file mode 100644
index 0000000..4e1856a
--- /dev/null
+++ b/benchmarks/regression/ByteBufferScalarVersusVectorBenchmark.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.nio.ByteBuffer;
+
+public class ByteBufferScalarVersusVectorBenchmark {
+ @Param private ByteBufferBenchmark.MyByteOrder byteOrder;
+ @Param({"true", "false"}) private boolean aligned;
+ @Param private ByteBufferBenchmark.MyBufferType bufferType;
+
+ public void timeManualByteBufferCopy(int reps) throws Exception {
+ ByteBuffer src = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ ByteBuffer dst = ByteBufferBenchmark.newBuffer(byteOrder, aligned, bufferType);
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(0);
+ dst.position(0);
+ for (int i = 0; i < 8192; ++i) {
+ dst.put(src.get());
+ }
+ }
+ }
+
+ public void timeByteBufferBulkGet(int reps) throws Exception {
+ ByteBuffer src = ByteBuffer.allocate(aligned ? 8192 : 8192 + 1);
+ byte[] dst = new byte[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ src.get(dst, 0, dst.length);
+ }
+ }
+
+ public void timeDirectByteBufferBulkGet(int reps) throws Exception {
+ ByteBuffer src = ByteBuffer.allocateDirect(aligned ? 8192 : 8192 + 1);
+ byte[] dst = new byte[8192];
+ for (int rep = 0; rep < reps; ++rep) {
+ src.position(aligned ? 0 : 1);
+ src.get(dst, 0, dst.length);
+ }
+ }
+}
diff --git a/benchmarks/regression/CharacterBenchmark.java b/benchmarks/regression/CharacterBenchmark.java
new file mode 100644
index 0000000..bd907f8
--- /dev/null
+++ b/benchmarks/regression/CharacterBenchmark.java
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+
+/**
+ * Tests various Character methods, intended for testing multiple
+ * implementations against each other.
+ */
+public class CharacterBenchmark {
+
+ @Param private CharacterSet characterSet;
+
+ @Param private Overload overload;
+
+ private char[] chars;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ this.chars = characterSet.chars;
+ }
+
+ public enum Overload { CHAR, INT }
+
+ public double nanosToUnits(double nanos) {
+ return nanos / 65536;
+ }
+
+ public enum CharacterSet {
+ ASCII(128),
+ UNICODE(65536);
+ final char[] chars;
+ CharacterSet(int size) {
+ this.chars = new char[65536];
+ for (int i = 0; i < 65536; ++i) {
+ chars[i] = (char) (i % size);
+ }
+ }
+ }
+
+ // A fake benchmark to give us a baseline.
+ public boolean timeIsSpace(int reps) {
+ boolean fake = false;
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ fake ^= ((char) ch == ' ');
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ fake ^= (ch == ' ');
+ }
+ }
+ }
+ return fake;
+ }
+
+ public void timeDigit(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.digit(chars[ch], 10);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.digit((int) chars[ch], 10);
+ }
+ }
+ }
+ }
+
+ public void timeGetNumericValue(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.getNumericValue(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.getNumericValue((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsDigit(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isDigit(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isDigit((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsIdentifierIgnorable(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isIdentifierIgnorable(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isIdentifierIgnorable((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsJavaIdentifierPart(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isJavaIdentifierPart(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isJavaIdentifierPart((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsJavaIdentifierStart(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isJavaIdentifierStart(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isJavaIdentifierStart((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsLetter(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLetter(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLetter((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsLetterOrDigit(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLetterOrDigit(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLetterOrDigit((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsLowerCase(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLowerCase(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isLowerCase((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsSpaceChar(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isSpaceChar(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isSpaceChar((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsUpperCase(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isUpperCase(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isUpperCase((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeIsWhitespace(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isWhitespace(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.isWhitespace((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeToLowerCase(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.toLowerCase(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.toLowerCase((int) chars[ch]);
+ }
+ }
+ }
+ }
+
+ public void timeToUpperCase(int reps) {
+ if (overload == Overload.CHAR) {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.toUpperCase(chars[ch]);
+ }
+ }
+ } else {
+ for (int i = 0; i < reps; ++i) {
+ for (int ch = 0; ch < 65536; ++ch) {
+ Character.toUpperCase((int) chars[ch]);
+ }
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/CharsetBenchmark.java b/benchmarks/regression/CharsetBenchmark.java
new file mode 100644
index 0000000..131dc8a
--- /dev/null
+++ b/benchmarks/regression/CharsetBenchmark.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+public class CharsetBenchmark {
+ @Param({ "1", "10", "100", "1000", "10000" })
+ private int length;
+
+ // canonical => canonical charset name
+ // built-in => guaranteed-present charset
+ // special-case => libcore treats this charset specially for performance
+ @Param({
+ "UTF-16", // canonical, built-in, non-special-case
+ "UTF-8", // canonical, built-in, special-case
+ "UTF8", // non-canonical, built-in, special-case
+ "ISO-8859-1", // canonical, built-in, special-case
+ "8859_1", // non-canonical, built-in, special-case
+ "ISO-8859-2", // canonical, non-built-in, non-special-case
+ "8859_2", // non-canonical, non-built-in, non-special-case
+ "US-ASCII", // canonical, built-in, special-case
+ "ASCII" // non-canonical, built-in, special-case
+ })
+ private String name;
+
+ public void time_new_String_BString(int reps) throws Exception {
+ byte[] bytes = makeBytes(makeString(length));
+ for (int i = 0; i < reps; ++i) {
+ new String(bytes, name);
+ }
+ }
+
+ public void time_new_String_BII(int reps) throws Exception {
+ byte[] bytes = makeBytes(makeString(length));
+ for (int i = 0; i < reps; ++i) {
+ new String(bytes, 0, bytes.length);
+ }
+ }
+
+ public void time_new_String_BIIString(int reps) throws Exception {
+ byte[] bytes = makeBytes(makeString(length));
+ for (int i = 0; i < reps; ++i) {
+ new String(bytes, 0, bytes.length, name);
+ }
+ }
+
+ public void time_String_getBytes(int reps) throws Exception {
+ String string = makeString(length);
+ for (int i = 0; i < reps; ++i) {
+ string.getBytes(name);
+ }
+ }
+
+ private static String makeString(int length) {
+ StringBuilder result = new StringBuilder(length);
+ for (int i = 0; i < length; ++i) {
+ result.append('A' + (i % 26));
+ }
+ return result.toString();
+ }
+
+ private static byte[] makeBytes(String s) {
+ try {
+ return s.getBytes("US-ASCII");
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+}
diff --git a/benchmarks/regression/CharsetForNameBenchmark.java b/benchmarks/regression/CharsetForNameBenchmark.java
new file mode 100644
index 0000000..d5b72e8
--- /dev/null
+++ b/benchmarks/regression/CharsetForNameBenchmark.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.nio.charset.Charset;
+
+public class CharsetForNameBenchmark {
+ // canonical => canonical charset name
+ // built-in => guaranteed-present charset
+ // special-case => libcore treats this charset specially for performance
+ @Param({
+ "UTF-16", // canonical, built-in, non-special-case
+ "UTF-8", // canonical, built-in, special-case
+ "UTF8", // non-canonical, built-in, special-case
+ "ISO-8859-1", // canonical, built-in, special-case
+ "8859_1", // non-canonical, built-in, special-case
+ "ISO-8859-2", // canonical, non-built-in, non-special-case
+ "8859_2", // non-canonical, non-built-in, non-special-case
+ "US-ASCII", // canonical, built-in, special-case
+ "ASCII" // non-canonical, built-in, special-case
+ })
+ private String charsetName;
+
+ public void timeCharsetForName(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Charset.forName(charsetName);
+ }
+ }
+}
diff --git a/benchmarks/regression/CharsetUtf8Benchmark.java b/benchmarks/regression/CharsetUtf8Benchmark.java
new file mode 100644
index 0000000..041e435
--- /dev/null
+++ b/benchmarks/regression/CharsetUtf8Benchmark.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package benchmarks.regression;
+
+import android.icu.lang.UCharacter;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * Decode the same size of ASCII, BMP, Supplementary character using fast-path UTF-8 decoder.
+ * The fast-path code is in {@link StringFactory#newStringFromBytes(byte[], int, int, Charset)}
+ */
+public class CharsetUtf8Benchmark {
+
+ private static final int NO_OF_BYTES = 0x400000; // 4MB
+ private static final byte[] ASCII = makeUnicodeRange(0, 0x7f, NO_OF_BYTES / 0x80);
+ private static final byte[] BMP2 = makeUnicodeRange(0x0080, 0x07ff, NO_OF_BYTES / 2 / 0x780);
+ private static final byte[] BMP3 = makeUnicodeRange(0x0800, 0xffff,
+ NO_OF_BYTES / 3 / 0xf000 /* 0x10000 - 0x0800 - no of surrogate code points */);
+ private static final byte[] SUPPLEMENTARY = makeUnicodeRange(0x10000, 0x10ffff,
+ NO_OF_BYTES / 4 / 0x100000);
+
+ private static byte[] makeUnicodeRange(int startingCodePoint, int endingCodePoint,
+ int repeated) {
+ StringBuilder builder = new StringBuilder();
+ for (int codePoint = startingCodePoint; codePoint <= endingCodePoint; codePoint++) {
+ if (codePoint < Character.MIN_SURROGATE || codePoint > Character.MAX_SURROGATE) {
+ builder.append(UCharacter.toString(codePoint));
+ }
+ }
+
+ String str = builder.toString();
+ builder = new StringBuilder();
+ for (int i = 0; i < repeated; i++) {
+ builder.append(str);
+ }
+ return builder.toString().getBytes();
+ }
+
+ public void time_ascii() {
+ new String(ASCII, StandardCharsets.UTF_8);
+ }
+
+ public void time_bmp2() {
+ new String(BMP2, StandardCharsets.UTF_8);
+ }
+
+ public void time_bmp3() {
+ new String(BMP3, StandardCharsets.UTF_8);
+ }
+
+ public void time_supplementary() {
+ new String(SUPPLEMENTARY, StandardCharsets.UTF_8);
+ }
+}
diff --git a/benchmarks/regression/ChecksumBenchmark.java b/benchmarks/regression/ChecksumBenchmark.java
new file mode 100644
index 0000000..61a95d7
--- /dev/null
+++ b/benchmarks/regression/ChecksumBenchmark.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.util.zip.Adler32;
+import java.util.zip.CRC32;
+
+public class ChecksumBenchmark {
+ public void timeAdler_block(int reps) throws Exception {
+ byte[] bytes = new byte[10000];
+ Adler32 adler = new Adler32();
+ for (int i = 0; i < reps; ++i) {
+ adler.update(bytes);
+ }
+ }
+ public void timeAdler_byte(int reps) throws Exception {
+ Adler32 adler = new Adler32();
+ for (int i = 0; i < reps; ++i) {
+ adler.update(1);
+ }
+ }
+ public void timeCrc_block(int reps) throws Exception {
+ byte[] bytes = new byte[10000];
+ CRC32 crc = new CRC32();
+ for (int i = 0; i < reps; ++i) {
+ crc.update(bytes);
+ }
+ }
+ public void timeCrc_byte(int reps) throws Exception {
+ CRC32 crc = new CRC32();
+ for (int i = 0; i < reps; ++i) {
+ crc.update(1);
+ }
+ }
+}
diff --git a/benchmarks/regression/CipherBenchmark.java b/benchmarks/regression/CipherBenchmark.java
new file mode 100644
index 0000000..31cbcc3
--- /dev/null
+++ b/benchmarks/regression/CipherBenchmark.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.security.spec.AlgorithmParameterSpec;
+import java.util.HashMap;
+import java.util.Map;
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * Cipher benchmarks. Only runs on AES currently because of the combinatorial
+ * explosion of the test as it stands.
+ */
+public class CipherBenchmark {
+
+ private static final int DATA_SIZE = 8192;
+ private static final byte[] DATA = new byte[DATA_SIZE];
+
+ private static final int IV_SIZE = 16;
+
+ private static final byte[] IV = new byte[IV_SIZE];
+
+ static {
+ for (int i = 0; i < DATA_SIZE; i++) {
+ DATA[i] = (byte) i;
+ }
+ for (int i = 0; i < IV_SIZE; i++) {
+ IV[i] = (byte) i;
+ }
+ }
+
+ @Param private Algorithm algorithm;
+
+ public enum Algorithm {
+ AES,
+ };
+
+ @Param private Mode mode;
+
+ public enum Mode {
+ CBC,
+ CFB,
+ CTR,
+ ECB,
+ OFB,
+ };
+
+ @Param private Padding padding;
+
+ public enum Padding {
+ NOPADDING,
+ PKCS1PADDING,
+ };
+
+ @Param({"128", "192", "256"}) private int keySize;
+
+ @Param({"16", "32", "64", "128", "1024", "8192"}) private int inputSize;
+
+ @Param private Implementation implementation;
+
+ public enum Implementation { OpenSSL, BouncyCastle };
+
+ private String providerName;
+
+ // Key generation isn't part of the benchmark so cache the results
+ private static Map<Integer, SecretKey> KEY_SIZES = new HashMap<Integer, SecretKey>();
+
+ private String cipherAlgorithm;
+ private SecretKey key;
+
+ private byte[] output = new byte[DATA.length];
+
+ private Cipher cipherEncrypt;
+
+ private Cipher cipherDecrypt;
+
+ private AlgorithmParameterSpec spec;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ cipherAlgorithm = algorithm.toString() + "/" + mode.toString() + "/"
+ + padding.toString();
+
+ String keyAlgorithm = algorithm.toString();
+ key = KEY_SIZES.get(keySize);
+ if (key == null) {
+ KeyGenerator generator = KeyGenerator.getInstance(keyAlgorithm);
+ generator.init(keySize);
+ key = generator.generateKey();
+ KEY_SIZES.put(keySize, key);
+ }
+
+ switch (implementation) {
+ case OpenSSL:
+ providerName = "AndroidOpenSSL";
+ break;
+ case BouncyCastle:
+ providerName = "BC";
+ break;
+ default:
+ throw new RuntimeException(implementation.toString());
+ }
+
+ if (mode != Mode.ECB) {
+ spec = new IvParameterSpec(IV);
+ }
+
+ cipherEncrypt = Cipher.getInstance(cipherAlgorithm, providerName);
+ cipherEncrypt.init(Cipher.ENCRYPT_MODE, key, spec);
+
+ cipherDecrypt = Cipher.getInstance(cipherAlgorithm, providerName);
+ cipherDecrypt.init(Cipher.DECRYPT_MODE, key, spec);
+ }
+
+ public void timeEncrypt(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ cipherEncrypt.doFinal(DATA, 0, inputSize, output);
+ }
+ }
+
+ public void timeDecrypt(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ cipherDecrypt.doFinal(DATA, 0, inputSize, output);
+ }
+ }
+}
diff --git a/benchmarks/regression/CipherInputStreamBenchmark.java b/benchmarks/regression/CipherInputStreamBenchmark.java
new file mode 100644
index 0000000..161002c
--- /dev/null
+++ b/benchmarks/regression/CipherInputStreamBenchmark.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.security.spec.AlgorithmParameterSpec;
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.IvParameterSpec;
+
+/**
+ * CipherInputStream benchmark.
+ */
+public class CipherInputStreamBenchmark {
+
+ private static final int DATA_SIZE = 1024 * 1024;
+ private static final byte[] DATA = new byte[DATA_SIZE];
+
+ private static final int IV_SIZE = 16;
+ private static final byte[] IV = new byte[IV_SIZE];
+
+ static {
+ for (int i = 0; i < DATA_SIZE; i++) {
+ DATA[i] = (byte) i;
+ }
+ for (int i = 0; i < IV_SIZE; i++) {
+ IV[i] = (byte) i;
+ }
+ }
+
+ private SecretKey key;
+
+ private byte[] output = new byte[8192];
+
+ private Cipher cipherEncrypt;
+
+ private AlgorithmParameterSpec spec;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ KeyGenerator generator = KeyGenerator.getInstance("AES");
+ generator.init(128);
+ key = generator.generateKey();
+
+ spec = new IvParameterSpec(IV);
+
+ cipherEncrypt = Cipher.getInstance("AES/CBC/PKCS5Padding");
+ cipherEncrypt.init(Cipher.ENCRYPT_MODE, key, spec);
+ }
+
+ public void timeEncrypt(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ cipherEncrypt.init(Cipher.ENCRYPT_MODE, key, spec);
+ InputStream is = new CipherInputStream(new ByteArrayInputStream(DATA), cipherEncrypt);
+ while (is.read(output) != -1) {
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/CollatorBenchmark.java b/benchmarks/regression/CollatorBenchmark.java
new file mode 100644
index 0000000..794f5ec
--- /dev/null
+++ b/benchmarks/regression/CollatorBenchmark.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.text.Collator;
+import java.text.RuleBasedCollator;
+import java.util.Locale;
+
+public class CollatorBenchmark {
+
+ private static final RuleBasedCollator collator = (RuleBasedCollator)
+ Collator.getInstance(Locale.US);
+
+ public void timeCollatorPrimary(int reps) {
+ collator.setStrength(Collator.PRIMARY);
+ for (int i = 0; i < reps; i++) {
+ collator.compare("abcde", "abcdf");
+ collator.compare("abcde", "abcde");
+ collator.compare("abcdf", "abcde");
+ }
+ }
+
+ public void timeCollatorSecondary(int reps) {
+ collator.setStrength(Collator.SECONDARY);
+ for (int i = 0; i < reps; i++) {
+ collator.compare("abcdÂ", "abcdÄ");
+ collator.compare("abcdÂ", "abcdÂ");
+ collator.compare("abcdÄ", "abcdÂ");
+ }
+ }
+
+ public void timeCollatorTertiary(int reps) {
+ collator.setStrength(Collator.TERTIARY);
+ for (int i = 0; i < reps; i++) {
+ collator.compare("abcdE", "abcde");
+ collator.compare("abcde", "abcde");
+ collator.compare("abcde", "abcdE");
+ }
+ }
+
+ public void timeCollatorIdentical(int reps) {
+ collator.setStrength(Collator.IDENTICAL);
+ for (int i = 0; i < reps; i++) {
+ collator.compare("abcdȪ", "abcdȫ");
+ collator.compare("abcdȪ", "abcdȪ");
+ collator.compare("abcdȫ", "abcdȪ");
+ }
+ }
+}
diff --git a/benchmarks/regression/CollectionsBenchmark.java b/benchmarks/regression/CollectionsBenchmark.java
new file mode 100644
index 0000000..00c1191
--- /dev/null
+++ b/benchmarks/regression/CollectionsBenchmark.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Random;
+import java.util.Vector;
+
+public class CollectionsBenchmark {
+ @Param({"4", "16", "64", "256", "1024"})
+ private int arrayListLength;
+
+ public static Comparator<Integer> REVERSE = new Comparator<Integer>() {
+ @Override
+ public int compare(Integer lhs, Integer rhs) {
+ int lhsAsInt = lhs.intValue();
+ int rhsAsInt = rhs.intValue();
+ return rhsAsInt < lhsAsInt ? -1 : (lhsAsInt == rhsAsInt ? 0 : 1);
+ }
+ };
+
+
+ public void timeSort_arrayList(int nreps) throws Exception {
+ List<Integer> input = buildList(arrayListLength, ArrayList.class);
+ for (int i = 0; i < nreps; ++i) {
+ Collections.sort(input);
+ }
+ }
+
+ public void timeSortWithComparator_arrayList(int nreps) throws Exception {
+ List<Integer> input = buildList(arrayListLength, ArrayList.class);
+ for (int i = 0; i < nreps; ++i) {
+ Collections.sort(input, REVERSE);
+ }
+ }
+
+ public void timeSort_vector(int nreps) throws Exception {
+ List<Integer> input = buildList(arrayListLength, Vector.class);
+ for (int i = 0; i < nreps; ++i) {
+ Collections.sort(input);
+ }
+ }
+
+ public void timeSortWithComparator_vector(int nreps) throws Exception {
+ List<Integer> input = buildList(arrayListLength, Vector.class);
+ for (int i = 0; i < nreps; ++i) {
+ Collections.sort(input, REVERSE);
+ }
+ }
+
+ private static <T extends List<Integer>> List<Integer> buildList(
+ int arrayListLength, Class<T> listClass) throws Exception {
+ Random random = new Random();
+ random.setSeed(0);
+ List<Integer> list = listClass.newInstance();
+ for (int i = 0; i < arrayListLength; ++i) {
+ list.add(random.nextInt());
+ }
+ return list;
+ }
+}
diff --git a/benchmarks/regression/DateFormatBenchmark.java b/benchmarks/regression/DateFormatBenchmark.java
new file mode 100644
index 0000000..bd5bf1a
--- /dev/null
+++ b/benchmarks/regression/DateFormatBenchmark.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+
+import java.text.DateFormat;
+import java.util.Locale;
+
+public final class DateFormatBenchmark {
+
+ private Locale locale1;
+ private Locale locale2;
+ private Locale locale3;
+ private Locale locale4;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ locale1 = Locale.TAIWAN;
+ locale2 = Locale.GERMANY;
+ locale3 = Locale.FRANCE;
+ locale4 = Locale.ITALY;
+ }
+
+ public void timeGetDateTimeInstance(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ DateFormat.getDateTimeInstance();
+ }
+ }
+
+ public void timeGetDateTimeInstance_multiple(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale1);
+ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale2);
+ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale3);
+ DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale4);
+ }
+ }
+}
diff --git a/benchmarks/regression/DecimalFormatBenchmark.java b/benchmarks/regression/DecimalFormatBenchmark.java
new file mode 100644
index 0000000..2436379
--- /dev/null
+++ b/benchmarks/regression/DecimalFormatBenchmark.java
@@ -0,0 +1,162 @@
+package benchmarks.regression;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.util.Locale;
+
+public class DecimalFormatBenchmark {
+
+ private static final String EXP_PATTERN = "##E0";
+
+ private static final DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance();
+ // Keep patternInstance for timing with patterns, to not dirty the plain instance.
+ private static final DecimalFormat patternInstance = (DecimalFormat)
+ DecimalFormat.getInstance();
+ private static final DecimalFormat dfCurrencyUS = (DecimalFormat)
+ NumberFormat.getCurrencyInstance(Locale.US);
+ private static final DecimalFormat dfCurrencyFR = (DecimalFormat)
+ NumberFormat.getInstance(Locale.FRANCE);
+
+ private static final BigDecimal BD10E3 = new BigDecimal("10E3");
+ private static final BigDecimal BD10E9 = new BigDecimal("10E9");
+ private static final BigDecimal BD10E100 = new BigDecimal("10E100");
+ private static final BigDecimal BD10E1000 = new BigDecimal("10E1000");
+
+ private static final int WHOLE_NUMBER = 10;
+ private static final double TWO_DP_NUMBER = 3.14;
+
+ public static void formatWithGrouping(Object obj, int reps) {
+ df.setGroupingSize(3);
+ df.setGroupingUsed(true);
+ for (int i = 0; i < reps; i++) {
+ df.format(obj);
+ }
+ }
+
+ public static void format(String pattern, Object obj, int reps) {
+ patternInstance.applyPattern(pattern);
+ for (int i = 0; i < reps; i++) {
+ patternInstance.format(obj);
+ }
+ }
+
+ public static void format(Object obj, int reps) {
+ for (int i = 0; i < reps; i++) {
+ df.format(obj);
+ }
+ }
+
+ public static void formatToCharacterIterator(Object obj, int reps) {
+ for (int i = 0; i < reps; i++) {
+ df.formatToCharacterIterator(obj);
+ }
+ }
+
+
+ public static void formatCurrencyUS(Object obj, int reps) {
+ for (int i = 0; i < reps; i++) {
+ dfCurrencyUS.format(obj);
+ }
+ }
+
+ public static void formatCurrencyFR(Object obj, int reps) {
+ for (int i = 0; i < reps; i++) {
+ dfCurrencyFR.format(obj);
+ }
+ }
+
+ public void time_formatGrouping_BigDecimal10e3(int reps) {
+ formatWithGrouping(BD10E3, reps);
+ }
+
+ public void time_formatGrouping_BigDecimal10e9(int reps) {
+ formatWithGrouping(BD10E9, reps);
+ }
+
+ public void time_formatGrouping_BigDecimal10e100(int reps) {
+ formatWithGrouping(BD10E100, reps);
+ }
+
+ public void time_formatGrouping_BigDecimal10e1000(int reps) {
+ formatWithGrouping(BD10E1000, reps);
+ }
+
+ public void time_formatBigDecimal10e3(int reps) {
+ format(BD10E3, reps);
+ }
+
+ public void time_formatBigDecimal10e9(int reps) {
+ format(BD10E9, reps);
+ }
+
+ public void time_formatBigDecimal10e100(int reps) {
+ format(BD10E100, reps);
+ }
+
+ public void time_formatBigDecimal10e1000(int reps) {
+ format(BD10E1000, reps);
+ }
+
+ public void time_formatPi(int reps) {
+ format(Math.PI, reps);
+ }
+
+ public void time_formatE(int reps) {
+ format(Math.E, reps);
+ }
+
+ public void time_formatUSD(int reps) {
+ formatCurrencyUS(WHOLE_NUMBER, reps);
+ }
+
+ public void time_formatUsdWithCents(int reps) {
+ formatCurrencyUS(TWO_DP_NUMBER, reps);
+ }
+
+ public void time_formatEur(int reps) {
+ formatCurrencyFR(WHOLE_NUMBER, reps);
+ }
+
+ public void time_formatEurWithCents(int reps) {
+ formatCurrencyFR(TWO_DP_NUMBER, reps);
+ }
+
+ public void time_formatAsExponent10e3(int reps) {
+ format(EXP_PATTERN, BD10E3, reps);
+ }
+
+ public void time_formatAsExponent10e9(int reps) {
+ format(EXP_PATTERN, BD10E9, reps);
+ }
+
+ public void time_formatAsExponent10e100(int reps) {
+ format(EXP_PATTERN, BD10E100, reps);
+ }
+
+ public void time_formatAsExponent10e1000(int reps) {
+ format(EXP_PATTERN, BD10E1000, reps);
+ }
+
+ public void time_formatToCharacterIterator10e3(int reps) {
+ formatToCharacterIterator(BD10E3, reps);
+ }
+
+ public void time_formatToCharacterIterator10e9(int reps) {
+ formatToCharacterIterator(BD10E9, reps);
+ }
+
+ public void time_formatToCharacterIterator10e100(int reps) {
+ formatToCharacterIterator(BD10E100, reps);
+ }
+
+ public void time_formatToCharacterIterator10e1000(int reps) {
+ formatToCharacterIterator(BD10E1000, reps);
+ }
+
+ public void time_instantiation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ new DecimalFormat();
+ }
+ }
+}
diff --git a/benchmarks/regression/DecimalFormatSymbolsBenchmark.java b/benchmarks/regression/DecimalFormatSymbolsBenchmark.java
new file mode 100644
index 0000000..381b9e1
--- /dev/null
+++ b/benchmarks/regression/DecimalFormatSymbolsBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package benchmarks.regression;
+
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
+
+public class DecimalFormatSymbolsBenchmark {
+
+ private static Locale locale = Locale.getDefault(Locale.Category.FORMAT);
+
+ public void time_instantiation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ new DecimalFormatSymbols(locale);
+ }
+ }
+}
diff --git a/benchmarks/regression/DefaultCharsetBenchmark.java b/benchmarks/regression/DefaultCharsetBenchmark.java
new file mode 100644
index 0000000..24283e4
--- /dev/null
+++ b/benchmarks/regression/DefaultCharsetBenchmark.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.nio.charset.Charset;
+
+public class DefaultCharsetBenchmark {
+ public void time_defaultCharset(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Charset.defaultCharset();
+ }
+ }
+}
diff --git a/benchmarks/regression/DnsBenchmark.java b/benchmarks/regression/DnsBenchmark.java
new file mode 100644
index 0000000..86bfa66
--- /dev/null
+++ b/benchmarks/regression/DnsBenchmark.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class DnsBenchmark {
+ public void timeDns(int reps) throws Exception {
+ String[] hosts = new String[] {
+ "www.amazon.com",
+ "z-ecx.images-amazon.com",
+ "g-ecx.images-amazon.com",
+ "ecx.images-amazon.com",
+ "ad.doubleclick.com",
+ "bpx.a9.com",
+ "d3dtik4dz1nej0.cloudfront.net",
+ "uac.advertising.com",
+ "servedby.advertising.com",
+ "view.atdmt.com",
+ "rmd.atdmt.com",
+ "spe.atdmt.com",
+ "www.google.com",
+ "www.cnn.com",
+ "bad.host.mtv.corp.google.com",
+ };
+ for (int i = 0; i < reps; ++i) {
+ try {
+ InetAddress.getByName(hosts[i % hosts.length]);
+ } catch (UnknownHostException ex) {
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/DoPrivilegedBenchmark.java b/benchmarks/regression/DoPrivilegedBenchmark.java
new file mode 100644
index 0000000..48b1fc8
--- /dev/null
+++ b/benchmarks/regression/DoPrivilegedBenchmark.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class DoPrivilegedBenchmark {
+ public void timeDirect(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ String lineSeparator = System.getProperty("line.separator");
+ }
+ }
+
+ public void timeFastAndSlow(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ String lineSeparator;
+ if (System.getSecurityManager() == null) {
+ lineSeparator = System.getProperty("line.separator");
+ } else {
+ lineSeparator = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("line.separator");
+ }
+ });
+ }
+ }
+ }
+
+ public void timeNewAction(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ String lineSeparator = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("line.separator");
+ }
+ });
+ }
+ }
+
+ public void timeReusedAction(int reps) throws Exception {
+ final PrivilegedAction<String> action = new ReusableAction("line.separator");
+ for (int i = 0; i < reps; ++i) {
+ String lineSeparator = AccessController.doPrivileged(action);
+ }
+ }
+
+ private static final class ReusableAction implements PrivilegedAction<String> {
+ private final String propertyName;
+
+ public ReusableAction(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public String run() {
+ return System.getProperty(propertyName);
+ }
+ }
+}
diff --git a/benchmarks/regression/DoubleBenchmark.java b/benchmarks/regression/DoubleBenchmark.java
new file mode 100644
index 0000000..546c17e
--- /dev/null
+++ b/benchmarks/regression/DoubleBenchmark.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class DoubleBenchmark {
+ private double d = 1.2;
+ private long l = 4608083138725491507L;
+
+ public void timeDoubleToLongBits(int reps) {
+ long result = 123;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Double.doubleToLongBits(d);
+ }
+ if (result != l) {
+ throw new RuntimeException(Long.toString(result));
+ }
+ }
+
+ public void timeDoubleToRawLongBits(int reps) {
+ long result = 123;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Double.doubleToRawLongBits(d);
+ }
+ if (result != l) {
+ throw new RuntimeException(Long.toString(result));
+ }
+ }
+
+ public void timeLongBitsToDouble(int reps) {
+ double result = 123.0;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Double.longBitsToDouble(l);
+ }
+ if (result != d) {
+ throw new RuntimeException(Double.toString(result) + " " + Double.doubleToRawLongBits(result));
+ }
+ }
+}
diff --git a/benchmarks/regression/EqualsHashCodeBenchmark.java b/benchmarks/regression/EqualsHashCodeBenchmark.java
new file mode 100644
index 0000000..0a303d6
--- /dev/null
+++ b/benchmarks/regression/EqualsHashCodeBenchmark.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.net.URI;
+import java.net.URL;
+
+public final class EqualsHashCodeBenchmark {
+ private enum Type {
+ URI() {
+ @Override Object newInstance(String text) throws Exception {
+ return new URI(text);
+ }
+ },
+ URL() {
+ @Override Object newInstance(String text) throws Exception {
+ return new URL(text);
+ }
+ };
+ abstract Object newInstance(String text) throws Exception;
+ }
+
+ private static final String QUERY = "%E0%AE%A8%E0%AE%BE%E0%AE%AE%E0%AF%8D+%E0%AE%AE%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%AF%E0%AE%AE%E0%AE%BE%E0%AE%A9%2C+%E0%AE%9A%E0%AF%81%E0%AE%B5%E0%AE%BE%E0%AE%B0%E0%AE%B8%E0%AF%8D%E0%AE%AF%E0%AE%AE%E0%AE%BE%E0%AE%A9+%E0%AE%87%E0%AE%B0%E0%AF%81%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AF%87%E0%AE%BE%E0%AE%AE%E0%AF%8D%2C+%E0%AE%86%E0%AE%A9%E0%AE%BE%E0%AE%B2%E0%AF%8D+%E0%AE%9A%E0%AE%BF%E0%AE%B2+%E0%AE%A8%E0%AF%87%E0%AE%B0%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%9A%E0%AF%82%E0%AE%B4%E0%AF%8D%E0%AE%A8%E0%AE%BF%E0%AE%B2%E0%AF%88+%E0%AE%8F%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%8E%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%A4%E0%AE%BE%E0%AE%B2%E0%AF%8D+%E0%AE%AA%E0%AE%A3%E0%AE%BF%E0%AE%AF%E0%AF%88%E0%AE%AF%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%B5%E0%AE%B2%E0%AE%BF+%E0%AE%85%E0%AE%B5%E0%AE%B0%E0%AF%88+%E0%AE%9A%E0%AE%BF%E0%AE%B2+%E0%AE%AA%E0%AF%86%E0%AE%B0%E0%AE%BF%E0%AE%AF+%E0%AE%95%E0%AF%86%E0%AE%BE%E0%AE%B3%E0%AF%8D%E0%AE%AE%E0%AF%81%E0%AE%A4%E0%AE%B2%E0%AF%8D+%E0%AE%AE%E0%AF%81%E0%AE%9F%E0%AE%BF%E0%AE%AF%E0%AF%81%E0%AE%AE%E0%AF%8D.+%E0%AE%85%E0%AE%A4%E0%AF%81+%E0%AE%9A%E0%AE%BF%E0%AE%B2+%E0%AE%A8%E0%AE%A9%E0%AF%8D%E0%AE%AE%E0%AF%88%E0%AE%95%E0%AE%B3%E0%AF%88+%E0%AE%AA%E0%AF%86%E0%AE%B1+%E0%AE%A4%E0%AE%B5%E0%AE%BF%E0%AE%B0%2C+%E0%AE%8E%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AF%87%E0%AE%BE%E0%AE%A4%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%89%E0%AE%B4%E0%AF%88%E0%AE%95%E0%AF%8D%E0%AE%95+%E0%AE%89%E0%AE%9F%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%AF%E0%AE%BF%E0%AE%B1%E0%AF%8D%E0%AE%9A%E0%AE%BF+%E0%AE%AE%E0%AF%87%E0%AE%B1%E0%AF%8D%E0%AE%95%E0%AF%86%E0%AE%BE%E0%AE%B3%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%B1%E0%AE%A4%E0%AF%81+%E0%AE%8E%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81+%E0%AE%87%E0%AE%A4%E0%AF%81+%E0%AE%92%E0%AE%B0%E0%AF%81+%E0%AE%9A%E0%AE%BF%E0%AE%B1%E0%AE%BF%E0%AE%AF+%E0%AE%89%E0%AE%A4%E0%AE%BE%E0%AE%B0%E0%AE%A3%E0%AE%AE%E0%AF%8D%2C+%E0%AE%8E%E0%AE%9F%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95.+%E0%AE%B0%E0%AE%AF%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%8E%E0%AE%A8%E0%AF%8D%E0%AE%A4+%E0%AE%B5%E0%AE%BF%E0%AE%B3%E0%AF%88%E0%AE%B5%E0%AE%BE%E0%AE%95+%E0%AE%87%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%AE%E0%AF%8D+%E0%AE%86%E0%AE%A9%E0%AF%8D%E0%AE%B2%E0%AF%88%E0%AE%A9%E0%AF%8D+%E0%AE%AA%E0%AE%AF%E0%AE%A9%E0%AF%8D%E0%AE%AA%E0%AE%BE%E0%AE%9F%E0%AF%81%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%87%E0%AE%B0%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95+%E0%AE%B5%E0%AF%87%E0%AE%A3%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%AF%E0%AE%BE%E0%AE%B0%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%B5%E0%AE%B1%E0%AF%81+%E0%AE%95%E0%AE%A3%E0%AF%8D%E0%AE%9F%E0%AF%81%E0%AE%AA%E0%AE%BF%E0%AE%9F%E0%AE%BF%E0%AE%95%E0%AF%8D%E0%AE%95+%E0%AE%B5%E0%AE%B0%E0%AF%81%E0%AE%AE%E0%AF%8D+%E0%AE%A8%E0%AE%BE%E0%AE%AE%E0%AF%8D+%E0%AE%A4%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AF%87%E0%AE%BE%E0%AE%A4%E0%AF%81+%E0%AE%87%E0%AE%B0%E0%AF%81%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%B1%E0%AF%87%E0%AE%BE%E0%AE%AE%E0%AF%8D.+%E0%AE%87%E0%AE%A8%E0%AF%8D%E0%AE%A4+%E0%AE%A8%E0%AE%BF%E0%AE%95%E0%AE%B4%E0%AF%8D%E0%AE%B5%E0%AF%81%E0%AE%95%E0%AE%B3%E0%AE%BF%E0%AE%B2%E0%AF%8D+%E0%AE%9A%E0%AF%86%E0%AE%AF%E0%AF%8D%E0%AE%A4%E0%AE%AA%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%85%E0%AE%AE%E0%AF%88%E0%AE%AA%E0%AF%8D%E0%AE%AA%E0%AE%BF%E0%AE%A9%E0%AF%8D+%E0%AE%95%E0%AE%A3%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AF%81%2C+%E0%AE%85%E0%AE%B5%E0%AE%B0%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%A4%E0%AE%B5%E0%AE%B1%E0%AF%81+%E0%AE%B5%E0%AE%BF%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AF%81+quae+%E0%AE%AA%E0%AE%9F%E0%AF%8D%E0%AE%9F%E0%AE%B1%E0%AF%88+%E0%AE%A8%E0%AF%80%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%B3%E0%AF%8D+%E0%AE%AA%E0%AE%B0%E0%AE%BF%E0%AE%A8%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%B0%E0%AF%88%E0%AE%95%E0%AF%8D%E0%AE%95%E0%AE%BF%E0%AE%B1%E0%AF%87%E0%AE%BE%E0%AE%AE%E0%AF%8D+%E0%AE%AE%E0%AF%86%E0%AE%A9%E0%AF%8D%E0%AE%AE%E0%AF%88%E0%AE%AF%E0%AE%BE%E0%AE%95+%E0%AE%AE%E0%AE%BE%E0%AE%B1%E0%AF%81%E0%AE%AE%E0%AF%8D";
+
+ @Param Type type;
+
+ Object a1;
+ Object a2;
+ Object b1;
+ Object b2;
+
+ Object c1;
+ Object c2;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ a1 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
+ a2 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
+ b1 = type.newInstance("http://developer.android.com/reference/java/net/URI.html");
+ b2 = type.newInstance("http://developer.android.com/reference/java/net/URI.html");
+
+ c1 = type.newInstance("http://developer.android.com/query?q=" + QUERY);
+ // Replace the very last char.
+ c2 = type.newInstance("http://developer.android.com/query?q=" + QUERY.substring(0, QUERY.length() - 3) + "%AF");
+ }
+
+ public void timeEquals(int reps) {
+ for (int i = 0; i < reps; i+=3) {
+ a1.equals(b1);
+ a1.equals(a2);
+ b1.equals(b2);
+ }
+ }
+
+ public void timeHashCode(int reps) {
+ for (int i = 0; i < reps; i+=2) {
+ a1.hashCode();
+ b1.hashCode();
+ }
+ }
+
+ public void timeEqualsWithHeavilyEscapedComponent(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ c1.equals(c2);
+ }
+ }
+}
diff --git a/benchmarks/regression/ExpensiveObjectsBenchmark.java b/benchmarks/regression/ExpensiveObjectsBenchmark.java
new file mode 100644
index 0000000..2777884
--- /dev/null
+++ b/benchmarks/regression/ExpensiveObjectsBenchmark.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.text.Collator;
+import java.text.DateFormat;
+import java.text.DateFormatSymbols;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+
+/**
+ * Benchmarks creation and cloning various expensive objects.
+ */
+public class ExpensiveObjectsBenchmark {
+ public void timeNewDateFormatTimeInstance(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
+ df.format(System.currentTimeMillis());
+ }
+ }
+
+ public void timeClonedDateFormatTimeInstance(int reps) {
+ DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
+ for (int i = 0; i < reps; ++i) {
+ ((DateFormat) df.clone()).format(System.currentTimeMillis());
+ }
+ }
+
+ public void timeReusedDateFormatTimeInstance(int reps) {
+ DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
+ for (int i = 0; i < reps; ++i) {
+ synchronized (df) {
+ df.format(System.currentTimeMillis());
+ }
+ }
+ }
+
+ public void timeNewCollator(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ Collator.getInstance(Locale.US);
+ }
+ }
+
+ public void timeClonedCollator(int reps) {
+ Collator c = Collator.getInstance(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ c.clone();
+ }
+ }
+
+ public void timeNewDateFormatSymbols(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ new DateFormatSymbols(Locale.US);
+ }
+ }
+
+ public void timeClonedDateFormatSymbols(int reps) {
+ DateFormatSymbols dfs = new DateFormatSymbols(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ dfs.clone();
+ }
+ }
+
+ public void timeNewDecimalFormatSymbols(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ new DecimalFormatSymbols(Locale.US);
+ }
+ }
+
+ public void timeClonedDecimalFormatSymbols(int reps) {
+ DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ dfs.clone();
+ }
+ }
+
+ public void timeNewNumberFormat(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ NumberFormat.getInstance(Locale.US);
+ }
+ }
+
+ public void timeClonedNumberFormat(int reps) {
+ NumberFormat nf = NumberFormat.getInstance(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ nf.clone();
+ }
+ }
+
+ public void timeNumberFormatTrivialFormatLong(int reps) {
+ NumberFormat nf = NumberFormat.getInstance(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ nf.format(1024L);
+ }
+ }
+
+ public void timeLongToString(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ Long.toString(1024L);
+ }
+ }
+
+ public void timeNumberFormatTrivialFormatDouble(int reps) {
+ NumberFormat nf = NumberFormat.getInstance(Locale.US);
+ for (int i = 0; i < reps; ++i) {
+ nf.format(1024.0);
+ }
+ }
+
+ public void timeNewSimpleDateFormat(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ new SimpleDateFormat();
+ }
+ }
+
+ public void timeClonedSimpleDateFormat(int reps) {
+ SimpleDateFormat sdf = new SimpleDateFormat();
+ for (int i = 0; i < reps; ++i) {
+ sdf.clone();
+ }
+ }
+
+ public void timeNewGregorianCalendar(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ new GregorianCalendar();
+ }
+ }
+
+ public void timeClonedGregorianCalendar(int reps) {
+ GregorianCalendar gc = new GregorianCalendar();
+ for (int i = 0; i < reps; ++i) {
+ gc.clone();
+ }
+ }
+}
diff --git a/benchmarks/regression/FileBenchmark.java b/benchmarks/regression/FileBenchmark.java
new file mode 100644
index 0000000..764247d
--- /dev/null
+++ b/benchmarks/regression/FileBenchmark.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks.regression;
+
+import java.io.File;
+
+public final class FileBenchmark {
+ public void timeFileCreationWithEmptyChild(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ new File("/foo", "/");
+ }
+ }
+
+ public void timeFileCreationWithNormalizationNecessary(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ new File("/foo//bar//baz//bag", "/baz/");
+ }
+ }
+}
diff --git a/benchmarks/regression/FloatBenchmark.java b/benchmarks/regression/FloatBenchmark.java
new file mode 100644
index 0000000..6964b01
--- /dev/null
+++ b/benchmarks/regression/FloatBenchmark.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class FloatBenchmark {
+ private float f = 1.2f;
+ private int i = 1067030938;
+
+ public void timeFloatToIntBits(int reps) {
+ int result = 123;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Float.floatToIntBits(f);
+ }
+ if (result != i) {
+ throw new RuntimeException(Integer.toString(result));
+ }
+ }
+
+ public void timeFloatToRawIntBits(int reps) {
+ int result = 123;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Float.floatToRawIntBits(f);
+ }
+ if (result != i) {
+ throw new RuntimeException(Integer.toString(result));
+ }
+ }
+
+ public void timeIntBitsToFloat(int reps) {
+ float result = 123.0f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Float.intBitsToFloat(i);
+ }
+ if (result != f) {
+ throw new RuntimeException(Float.toString(result) + " " + Float.floatToRawIntBits(result));
+ }
+ }
+}
diff --git a/benchmarks/regression/FormatterBenchmark.java b/benchmarks/regression/FormatterBenchmark.java
new file mode 100644
index 0000000..091e7ea
--- /dev/null
+++ b/benchmarks/regression/FormatterBenchmark.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.util.Formatter;
+import java.util.Locale;
+
+/**
+ * Compares Formatter against hand-written StringBuilder code.
+ */
+public class FormatterBenchmark {
+ public void timeFormatter_NoFormatting(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that doesn't actually need any formatting");
+ }
+ }
+
+ public void timeStringBuilder_NoFormatting(int reps) {
+ for (int i = 0; i < reps; i++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("this is a reasonably short string that doesn't actually need any formatting");
+ }
+ }
+
+ public void timeFormatter_OneInt(int reps) {
+ Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has an int %d in it", value);
+ }
+ }
+
+ public void timeFormatter_OneIntArabic(int reps) {
+ Locale arabic = new Locale("ar");
+ Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format(arabic, "this is a reasonably short string that has an int %d in it", value);
+ }
+ }
+
+ public void timeStringBuilder_OneInt(int reps) {
+ for (int i = 0; i < reps; i++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("this is a reasonably short string that has an int ");
+ sb.append(1024);
+ sb.append(" in it");
+ }
+ }
+
+ public void timeFormatter_OneHexInt(int reps) {
+ Integer value = Integer.valueOf(1024); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has an int %x in it", value);
+ }
+ }
+
+ public void timeStringBuilder_OneHexInt(int reps) {
+ for (int i = 0; i < reps; i++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("this is a reasonably short string that has an int ");
+ sb.append(Integer.toHexString(1024));
+ sb.append(" in it");
+ }
+ }
+
+ public void timeFormatter_OneFloat(int reps) {
+ Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has a float %f in it", value);
+ }
+ }
+
+ public void timeFormatter_OneFloat_dot2f(int reps) {
+ Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has a float %.2f in it", value);
+ }
+ }
+
+ public void timeFormatter_TwoFloats(int reps) {
+ Float value = Float.valueOf(10.24f); // We're not trying to benchmark boxing here.
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has two floats %f and %f in it", value, value);
+ }
+ }
+
+ public void timeStringBuilder_OneFloat(int reps) {
+ for (int i = 0; i < reps; i++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("this is a reasonably short string that has a float ");
+ sb.append(10.24f);
+ sb.append(" in it");
+ }
+ }
+
+ public void timeFormatter_OneString(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Formatter f = new Formatter();
+ f.format("this is a reasonably short string that has a string %s in it", "hello");
+ }
+ }
+
+ public void timeStringBuilder_OneString(int reps) {
+ for (int i = 0; i < reps; i++) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("this is a reasonably short string that has a string ");
+ sb.append("hello");
+ sb.append(" in it");
+ }
+ }
+}
diff --git a/benchmarks/regression/HostnameVerifierBenchmark.java b/benchmarks/regression/HostnameVerifierBenchmark.java
new file mode 100644
index 0000000..9bf72a8
--- /dev/null
+++ b/benchmarks/regression/HostnameVerifierBenchmark.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.ByteArrayInputStream;
+import java.net.URL;
+import java.security.Principal;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateFactory;
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSessionContext;
+
+/**
+ * This benchmark makes a real HTTP connection to a handful of hosts and
+ * captures the served certificates as a byte array. It then verifies each
+ * certificate in the benchmark loop, being careful to convert from the
+ * byte[] to the certificate each time. Otherwise the certificate class
+ * caches previous results which skews the results of the benchmark: In practice
+ * each certificate instance is verified once and then released.
+ */
+public final class HostnameVerifierBenchmark {
+
+ @Param({"android.clients.google.com",
+ "m.google.com",
+ "www.google.com",
+ "www.amazon.com",
+ "www.ubs.com"}) String host;
+
+ private String hostname;
+ private HostnameVerifier hostnameVerifier;
+ private byte[][] encodedCertificates;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ URL url = new URL("https", host, "/");
+ hostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier();
+ HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
+ connection.setHostnameVerifier(new HostnameVerifier() {
+ public boolean verify(String hostname, SSLSession sslSession) {
+ try {
+ encodedCertificates = certificatesToBytes(sslSession.getPeerCertificates());
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ HostnameVerifierBenchmark.this.hostname = hostname;
+ return true;
+ }
+ });
+ connection.getInputStream();
+ connection.disconnect();
+ }
+
+ public void timeVerify(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ final Certificate[] certificates = bytesToCertificates(encodedCertificates);
+ FakeSSLSession sslSession = new FakeSSLSession() {
+ @Override public Certificate[] getPeerCertificates() {
+ return certificates;
+ }
+ };
+ hostnameVerifier.verify(hostname, sslSession);
+ }
+ }
+
+ private byte[][] certificatesToBytes(Certificate[] certificates) throws Exception {
+ byte[][] result = new byte[certificates.length][];
+ for (int i = 0, certificatesLength = certificates.length; i < certificatesLength; i++) {
+ result[i] = certificates[i].getEncoded();
+ }
+ return result;
+ }
+
+ private Certificate[] bytesToCertificates(byte[][] encodedCertificates) throws Exception {
+ CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
+ Certificate[] result = new Certificate[encodedCertificates.length];
+ for (int i = 0; i < encodedCertificates.length; i++) {
+ result[i] = certificateFactory.generateCertificate(
+ new ByteArrayInputStream(encodedCertificates[i]));
+ }
+ return result;
+ }
+
+ private static class FakeSSLSession implements SSLSession {
+ public int getApplicationBufferSize() {
+ throw new UnsupportedOperationException();
+ }
+ public String getCipherSuite() {
+ throw new UnsupportedOperationException();
+ }
+ public long getCreationTime() {
+ throw new UnsupportedOperationException();
+ }
+ public byte[] getId() {
+ throw new UnsupportedOperationException();
+ }
+ public long getLastAccessedTime() {
+ throw new UnsupportedOperationException();
+ }
+ public Certificate[] getLocalCertificates() {
+ throw new UnsupportedOperationException();
+ }
+ public Principal getLocalPrincipal() {
+ throw new UnsupportedOperationException();
+ }
+ public int getPacketBufferSize() {
+ throw new UnsupportedOperationException();
+ }
+ public javax.security.cert.X509Certificate[] getPeerCertificateChain() {
+ throw new UnsupportedOperationException();
+ }
+ public Certificate[] getPeerCertificates() {
+ throw new UnsupportedOperationException();
+ }
+ public String getPeerHost() {
+ throw new UnsupportedOperationException();
+ }
+ public int getPeerPort() {
+ throw new UnsupportedOperationException();
+ }
+ public Principal getPeerPrincipal() {
+ throw new UnsupportedOperationException();
+ }
+ public String getProtocol() {
+ throw new UnsupportedOperationException();
+ }
+ public SSLSessionContext getSessionContext() {
+ throw new UnsupportedOperationException();
+ }
+ public Object getValue(String name) {
+ throw new UnsupportedOperationException();
+ }
+ public String[] getValueNames() {
+ throw new UnsupportedOperationException();
+ }
+ public void invalidate() {
+ throw new UnsupportedOperationException();
+ }
+ public boolean isValid() {
+ throw new UnsupportedOperationException();
+ }
+ public void putValue(String name, Object value) {
+ throw new UnsupportedOperationException();
+ }
+ public void removeValue(String name) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/benchmarks/regression/IdnBenchmark.java b/benchmarks/regression/IdnBenchmark.java
new file mode 100644
index 0000000..6a40d01
--- /dev/null
+++ b/benchmarks/regression/IdnBenchmark.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.net.IDN;
+
+public class IdnBenchmark {
+
+ public void timeToUnicode(int reps) {
+ for (int i = 0; i < reps; i++) {
+ IDN.toASCII("fass.de");
+ IDN.toASCII("faß.de");
+ IDN.toASCII("fäß.de");
+ IDN.toASCII("a\u200Cb");
+ IDN.toASCII("öbb.at");
+ IDN.toASCII("abc・日本.co.jp");
+ IDN.toASCII("日本.co.jp");
+ IDN.toASCII("x\u0327\u0301.de");
+ IDN.toASCII("σόλοσ.gr");
+ }
+ }
+
+ public void timeToAscii(int reps) {
+ for (int i = 0; i < reps; i++) {
+ IDN.toUnicode("xn--fss-qla.de");
+ IDN.toUnicode("xn--n00d.com");
+ IDN.toUnicode("xn--bb-eka.at");
+ IDN.toUnicode("xn--og-09a.de");
+ IDN.toUnicode("xn--53h.de");
+ IDN.toUnicode("xn--iny-zx5a.de");
+ IDN.toUnicode("xn--abc-rs4b422ycvb.co.jp");
+ IDN.toUnicode("xn--wgv71a.co.jp");
+ IDN.toUnicode("xn--x-xbb7i.de");
+ IDN.toUnicode("xn--wxaikc6b.gr");
+ IDN.toUnicode("xn--wxaikc6b.xn--gr-gtd9a1b0g.de");
+ }
+ }
+
+}
diff --git a/benchmarks/regression/IntConstantDivisionBenchmark.java b/benchmarks/regression/IntConstantDivisionBenchmark.java
new file mode 100644
index 0000000..533461b
--- /dev/null
+++ b/benchmarks/regression/IntConstantDivisionBenchmark.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class IntConstantDivisionBenchmark {
+ public int timeDivideIntByConstant2(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result /= 2;
+ }
+ return result;
+ }
+ public int timeDivideIntByConstant8(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result /= 8;
+ }
+ return result;
+ }
+ public int timeDivideIntByConstant10(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result /= 10;
+ }
+ return result;
+ }
+ public int timeDivideIntByConstant100(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result /= 100;
+ }
+ return result;
+ }
+ public int timeDivideIntByConstant100_HandOptimized(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result = (int) ((0x51eb851fL * result) >>> 37);
+ }
+ return result;
+ }
+ public int timeDivideIntByConstant2048(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result /= 2048;
+ }
+ return result;
+ }
+ public int timeDivideIntByVariable2(int reps) {
+ int result = 1;
+ int factor = 2;
+ for (int i = 0; i < reps; ++i) {
+ result /= factor;
+ }
+ return result;
+ }
+ public int timeDivideIntByVariable10(int reps) {
+ int result = 1;
+ int factor = 10;
+ for (int i = 0; i < reps; ++i) {
+ result /= factor;
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/regression/IntConstantMultiplicationBenchmark.java b/benchmarks/regression/IntConstantMultiplicationBenchmark.java
new file mode 100644
index 0000000..cc096d6
--- /dev/null
+++ b/benchmarks/regression/IntConstantMultiplicationBenchmark.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class IntConstantMultiplicationBenchmark {
+ public int timeMultiplyIntByConstant6(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 6;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant7(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 7;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant8(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 8;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant8_Shift(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result <<= 3;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant10(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 10;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant10_Shift(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result = (result + (result << 2)) << 1;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant2047(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 2047;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant2048(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 2048;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByConstant2049(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result *= 2049;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByVariable10(int reps) {
+ int result = 1;
+ int factor = 10;
+ for (int i = 0; i < reps; ++i) {
+ result *= factor;
+ }
+ return result;
+ }
+ public int timeMultiplyIntByVariable8(int reps) {
+ int result = 1;
+ int factor = 8;
+ for (int i = 0; i < reps; ++i) {
+ result *= factor;
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/regression/IntConstantRemainderBenchmark.java b/benchmarks/regression/IntConstantRemainderBenchmark.java
new file mode 100644
index 0000000..b22868d
--- /dev/null
+++ b/benchmarks/regression/IntConstantRemainderBenchmark.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class IntConstantRemainderBenchmark {
+ public int timeRemainderIntByConstant2(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result %= 2;
+ }
+ return result;
+ }
+ public int timeRemainderIntByConstant8(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result %= 8;
+ }
+ return result;
+ }
+/*
+ public int timeRemainderIntByConstant10(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result %= 10;
+ }
+ return result;
+ }
+ public int timeRemainderIntByConstant100(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result %= 100;
+ }
+ return result;
+ }
+*/
+ public int timeRemainderIntByConstant2048(int reps) {
+ int result = 1;
+ for (int i = 0; i < reps; ++i) {
+ result %= 2048;
+ }
+ return result;
+ }
+ public int timeRemainderIntByVariable2(int reps) {
+ int result = 1;
+ int factor = 2;
+ for (int i = 0; i < reps; ++i) {
+ result %= factor;
+ }
+ return result;
+ }
+/*
+ public int timeRemainderIntByVariable10(int reps) {
+ int result = 1;
+ int factor = 10;
+ for (int i = 0; i < reps; ++i) {
+ result %= factor;
+ }
+ return result;
+ }
+*/
+}
diff --git a/benchmarks/regression/IntegerBenchmark.java b/benchmarks/regression/IntegerBenchmark.java
new file mode 100644
index 0000000..c9614d4
--- /dev/null
+++ b/benchmarks/regression/IntegerBenchmark.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class IntegerBenchmark {
+ public int timeLongSignumBranch(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += signum1(-i);
+ t += signum1(0);
+ t += signum1(i);
+ }
+ return t;
+ }
+
+ public int timeLongSignumBranchFree(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += signum2(-i);
+ t += signum2(0);
+ t += signum2(i);
+ }
+ return t;
+ }
+
+ private static int signum1(long v) {
+ return v < 0 ? -1 : (v == 0 ? 0 : 1);
+ }
+
+ private static int signum2(long v) {
+ return ((int)(v >> 63)) | (int) (-v >>> 63); // Hacker's delight 2-7
+ }
+
+ public int timeLongBitCount_BitSet(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += pop((long) i);
+ }
+ return t;
+ }
+
+ private static int pop(long l) {
+ int count = popX(l & 0xffffffffL);
+ count += popX(l >>> 32);
+ return count;
+ }
+
+ private static int popX(long x) {
+ // BEGIN android-note
+ // delegate to Integer.bitCount(i); consider using native code
+ // END android-note
+ x = x - ((x >>> 1) & 0x55555555);
+ x = (x & 0x33333333) + ((x >>> 2) & 0x33333333);
+ x = (x + (x >>> 4)) & 0x0f0f0f0f;
+ x = x + (x >>> 8);
+ x = x + (x >>> 16);
+ return (int) x & 0x0000003f;
+ }
+
+ public int timeLongBitCount_2Int(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += pop2((long) i);
+ }
+ return t;
+ }
+
+ private static int pop2(long l) {
+ int count = Integer.bitCount((int) (l & 0xffffffffL));
+ count += Integer.bitCount((int) (l >>> 32));
+ return count;
+ }
+
+ public int timeLongBitCount_Long(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += Long.bitCount((long) i);
+ }
+ return t;
+ }
+
+ /**
+ * Table for Seal's algorithm for Number of Trailing Zeros. Hacker's Delight
+ * online, Figure 5-18 (http://www.hackersdelight.org/revisions.pdf)
+ * The entries whose value is -1 are never referenced.
+ */
+ private static final byte[] NTZ_TABLE = {
+ 32, 0, 1, 12, 2, 6, -1, 13, 3, -1, 7, -1, -1, -1, -1, 14,
+ 10, 4, -1, -1, 8, -1, -1, 25, -1, -1, -1, -1, -1, 21, 27, 15,
+ 31, 11, 5, -1, -1, -1, -1, -1, 9, -1, -1, 24, -1, -1, 20, 26,
+ 30, -1, -1, -1, -1, 23, -1, 19, 29, -1, 22, 18, 28, 17, 16, -1
+ };
+
+ private static int numberOfTrailingZerosHD(int i) {
+ // Seal's algorithm - Hacker's Delight 5-18
+ i &= -i;
+ i = (i << 4) + i; // x *= 17
+ i = (i << 6) + i; // x *= 65
+ i = (i << 16) - i; // x *= 65535
+ return NTZ_TABLE[i >>> 26];
+ }
+
+ private static int numberOfTrailingZerosOL(int i) {
+ return NTZ_TABLE[((i & -i) * 0x0450FBAF) >>> 26];
+ }
+
+ public int timeNumberOfTrailingZerosHD(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += numberOfTrailingZerosHD(i);
+ }
+ return t;
+ }
+
+ public int timeNumberOfTrailingZerosOL(int reps) {
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ t += numberOfTrailingZerosOL(i);
+ }
+ return t;
+ }
+
+ public int timeIntegerValueOf(int reps) throws Exception {
+ String[] intStrings = new String[]{"0", "1", "12", "123", "1234", "12345",
+ "123456", "1234567", "12345678"};
+ int t = 0;
+ for (int i = 0; i < reps; ++i) {
+ for (int j = 0; j < intStrings.length; ++j) {
+ t += Integer.valueOf(intStrings[j]);
+ }
+ }
+ return t;
+ }
+}
diff --git a/benchmarks/regression/IntegralToStringBenchmark.java b/benchmarks/regression/IntegralToStringBenchmark.java
new file mode 100644
index 0000000..3445849
--- /dev/null
+++ b/benchmarks/regression/IntegralToStringBenchmark.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class IntegralToStringBenchmark {
+
+ private static final int SMALL = 12;
+ private static final int MEDIUM = 12345;
+ private static final int LARGE = 12345678;
+
+ public void time_IntegerToString_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(SMALL);
+ }
+ }
+
+ public void time_IntegerToString_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(MEDIUM);
+ }
+ }
+
+ public void time_IntegerToString_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(LARGE);
+ }
+ }
+
+ public void time_IntegerToString2_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(SMALL, 2);
+ }
+ }
+
+ public void time_IntegerToString2_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(MEDIUM, 2);
+ }
+ }
+
+ public void time_IntegerToString2_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(LARGE, 2);
+ }
+ }
+
+ public void time_IntegerToString10_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(SMALL, 10);
+ }
+ }
+
+ public void time_IntegerToString10_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(MEDIUM, 10);
+ }
+ }
+
+ public void time_IntegerToString10_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(LARGE, 10);
+ }
+ }
+
+ public void time_IntegerToString16_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(SMALL, 16);
+ }
+ }
+
+ public void time_IntegerToString16_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(MEDIUM, 16);
+ }
+ }
+
+ public void time_IntegerToString16_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toString(LARGE, 16);
+ }
+ }
+
+ public void time_IntegerToBinaryString_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toBinaryString(SMALL);
+ }
+ }
+
+ public void time_IntegerToBinaryString_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toBinaryString(MEDIUM);
+ }
+ }
+
+ public void time_IntegerToBinaryString_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toBinaryString(LARGE);
+ }
+ }
+
+ public void time_IntegerToHexString_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toHexString(SMALL);
+ }
+ }
+
+ public void time_IntegerToHexString_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toHexString(MEDIUM);
+ }
+ }
+
+ public void time_IntegerToHexString_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Integer.toHexString(LARGE);
+ }
+ }
+
+ public void time_StringBuilder_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(SMALL);
+ }
+ }
+
+ public void time_StringBuilder_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(MEDIUM);
+ }
+ }
+
+ public void time_StringBuilder_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(LARGE);
+ }
+ }
+
+ public void time_Formatter_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%d", SMALL);
+ }
+ }
+
+ public void time_Formatter_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%d", MEDIUM);
+ }
+ }
+
+ public void time_Formatter_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%d", LARGE);
+ }
+ }
+}
diff --git a/benchmarks/regression/JarFileBenchmark.java b/benchmarks/regression/JarFileBenchmark.java
new file mode 100644
index 0000000..1eff10b
--- /dev/null
+++ b/benchmarks/regression/JarFileBenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class JarFileBenchmark {
+ @Param({
+ "/system/framework/core-oj.jar",
+ "/system/priv-app/Phonesky/Phonesky.apk"
+ })
+ private String filename;
+
+ public void time(int reps) throws Exception {
+ File f = new File(filename);
+ for (int i = 0; i < reps; ++i) {
+ JarFile jf = new JarFile(f);
+ Manifest m = jf.getManifest();
+ jf.close();
+ }
+ }
+}
diff --git a/benchmarks/regression/KeyPairGeneratorBenchmark.java b/benchmarks/regression/KeyPairGeneratorBenchmark.java
new file mode 100644
index 0000000..75c71b4
--- /dev/null
+++ b/benchmarks/regression/KeyPairGeneratorBenchmark.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2012 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.SecureRandom;
+
+public class KeyPairGeneratorBenchmark {
+ @Param private Algorithm algorithm;
+
+ public enum Algorithm {
+ RSA,
+ DSA,
+ };
+
+ @Param private Implementation implementation;
+
+ public enum Implementation { OpenSSL, BouncyCastle };
+
+ private String generatorAlgorithm;
+ private KeyPairGenerator generator;
+ private SecureRandom random;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ this.generatorAlgorithm = algorithm.toString();
+
+ final String provider;
+ if (implementation == Implementation.BouncyCastle) {
+ provider = "BC";
+ } else {
+ provider = "AndroidOpenSSL";
+ }
+
+ this.generator = KeyPairGenerator.getInstance(generatorAlgorithm, provider);
+ this.random = SecureRandom.getInstance("SHA1PRNG");
+ this.generator.initialize(1024);
+ }
+
+ public void time(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ KeyPair keyPair = generator.generateKeyPair();
+ }
+ }
+}
diff --git a/benchmarks/regression/LoopingBackwardsBenchmark.java b/benchmarks/regression/LoopingBackwardsBenchmark.java
new file mode 100644
index 0000000..7456af2
--- /dev/null
+++ b/benchmarks/regression/LoopingBackwardsBenchmark.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+/**
+ * Testing the old canard that looping backwards is faster.
+ *
+ * @author Kevin Bourrillion
+ */
+public class LoopingBackwardsBenchmark {
+ @Param({"2", "20", "2000", "20000000"}) int max;
+
+ public int timeForwards(int reps) {
+ int fake = 0;
+ for (int i = 0; i < reps; i++) {
+ for (int j = 0; j < max; j++) {
+ fake += j;
+ }
+ }
+ return fake;
+ }
+
+ public int timeBackwards(int reps) {
+ int fake = 0;
+ for (int i = 0; i < reps; i++) {
+ for (int j = max - 1; j >= 0; j--) {
+ fake += j;
+ }
+ }
+ return fake;
+ }
+}
diff --git a/benchmarks/regression/MathBenchmark.java b/benchmarks/regression/MathBenchmark.java
new file mode 100644
index 0000000..41426b5
--- /dev/null
+++ b/benchmarks/regression/MathBenchmark.java
@@ -0,0 +1,481 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+/**
+ * Many of these tests are bogus in that the cost will vary wildly depending on inputs.
+ * For _my_ current purposes, that's okay. But beware!
+ */
+public class MathBenchmark {
+ private final double d = 1.2;
+ private final float f = 1.2f;
+ private final int i = 1;
+ private final long l = 1L;
+
+ // NOTE: To avoid the benchmarked function from being optimized away, we store the result
+ // and use it as the benchmark's return value. This is good enough for now but may not be in
+ // the future, a smart compiler could determine that the result value will depend on whether
+ // we get into the loop or not and turn the whole loop into an if statement.
+
+ public double timeAbsD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.abs(d);
+ }
+ return result;
+ }
+
+ public float timeAbsF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.abs(f);
+ }
+ return result;
+ }
+
+ public int timeAbsI(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.abs(i);
+ }
+ return result;
+ }
+
+ public long timeAbsL(int reps) {
+ long result = l;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.abs(l);
+ }
+ return result;
+ }
+
+ public double timeAcos(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.acos(d);
+ }
+ return result;
+ }
+
+ public double timeAsin(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.asin(d);
+ }
+ return result;
+ }
+
+ public double timeAtan(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.atan(d);
+ }
+ return result;
+ }
+
+ public double timeAtan2(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.atan2(3, 4);
+ }
+ return result;
+ }
+
+ public double timeCbrt(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.cbrt(d);
+ }
+ return result;
+ }
+
+ public double timeCeil(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.ceil(d);
+ }
+ return result;
+ }
+
+ public double timeCopySignD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.copySign(d, d);
+ }
+ return result;
+ }
+
+ public float timeCopySignF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.copySign(f, f);
+ }
+ return result;
+ }
+
+ public double timeCopySignD_strict(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = StrictMath.copySign(d, d);
+ }
+ return result;
+ }
+
+ public float timeCopySignF_strict(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = StrictMath.copySign(f, f);
+ }
+ return result;
+ }
+
+ public double timeCos(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.cos(d);
+ }
+ return result;
+ }
+
+ public double timeCosh(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.cosh(d);
+ }
+ return result;
+ }
+
+ public double timeExp(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.exp(d);
+ }
+ return result;
+ }
+
+ public double timeExpm1(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.expm1(d);
+ }
+ return result;
+ }
+
+ public double timeFloor(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.floor(d);
+ }
+ return result;
+ }
+
+ public int timeGetExponentD(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.getExponent(d);
+ }
+ return result;
+ }
+
+ public int timeGetExponentF(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.getExponent(f);
+ }
+ return result;
+ }
+
+ public double timeHypot(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.hypot(d, d);
+ }
+ return result;
+ }
+
+ public double timeIEEEremainder(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.IEEEremainder(d, d);
+ }
+ return result;
+ }
+
+ public double timeLog(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.log(d);
+ }
+ return result;
+ }
+
+ public double timeLog10(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.log10(d);
+ }
+ return result;
+ }
+
+ public double timeLog1p(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.log1p(d);
+ }
+ return result;
+ }
+
+ public double timeMaxD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.max(d, d);
+ }
+ return result;
+ }
+
+ public float timeMaxF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.max(f, f);
+ }
+ return result;
+ }
+
+ public int timeMaxI(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.max(i, i);
+ }
+ return result;
+ }
+
+ public long timeMaxL(int reps) {
+ long result = l;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.max(l, l);
+ }
+ return result;
+ }
+
+ public double timeMinD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.min(d, d);
+ }
+ return result;
+ }
+
+ public float timeMinF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.min(f, f);
+ }
+ return result;
+ }
+
+ public int timeMinI(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.min(i, i);
+ }
+ return result;
+ }
+
+ public long timeMinL(int reps) {
+ long result = l;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.min(l, l);
+ }
+ return result;
+ }
+
+ public double timeNextAfterD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.nextAfter(d, d);
+ }
+ return result;
+ }
+
+ public float timeNextAfterF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.nextAfter(f, f);
+ }
+ return result;
+ }
+
+ public double timeNextUpD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.nextUp(d);
+ }
+ return result;
+ }
+
+ public float timeNextUpF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.nextUp(f);
+ }
+ return result;
+ }
+
+ public double timePow(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.pow(d, d);
+ }
+ return result;
+ }
+
+ public double timeRandom(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.random();
+ }
+ return result;
+ }
+
+ public double timeRint(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.rint(d);
+ }
+ return result;
+ }
+
+ public long timeRoundD(int reps) {
+ long result = l;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.round(d);
+ }
+ return result;
+ }
+
+ public int timeRoundF(int reps) {
+ int result = i;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.round(f);
+ }
+ return result;
+ }
+
+ public double timeScalbD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.scalb(d, 5);
+ }
+ return result;
+ }
+
+ public float timeScalbF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.scalb(f, 5);
+ }
+ return result;
+ }
+
+ public double timeSignumD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.signum(d);
+ }
+ return result;
+ }
+
+ public float timeSignumF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.signum(f);
+ }
+ return result;
+ }
+
+ public double timeSin(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.sin(d);
+ }
+ return result;
+ }
+
+ public double timeSinh(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.sinh(d);
+ }
+ return result;
+ }
+
+ public double timeSqrt(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.sqrt(d);
+ }
+ return result;
+ }
+
+ public double timeTan(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.tan(d);
+ }
+ return result;
+ }
+
+ public double timeTanh(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.tanh(d);
+ }
+ return result;
+ }
+
+ public double timeToDegrees(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.toDegrees(d);
+ }
+ return result;
+ }
+
+ public double timeToRadians(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.toRadians(d);
+ }
+ return result;
+ }
+
+ public double timeUlpD(int reps) {
+ double result = d;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.ulp(d);
+ }
+ return result;
+ }
+
+ public float timeUlpF(int reps) {
+ float result = f;
+ for (int rep = 0; rep < reps; ++rep) {
+ result = Math.ulp(f);
+ }
+ return result;
+ }
+}
diff --git a/benchmarks/regression/MessageDigestBenchmark.java b/benchmarks/regression/MessageDigestBenchmark.java
new file mode 100644
index 0000000..40819f8
--- /dev/null
+++ b/benchmarks/regression/MessageDigestBenchmark.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.nio.ByteBuffer;
+import java.security.MessageDigest;
+
+public class MessageDigestBenchmark {
+
+ private static final int DATA_SIZE = 8192;
+ private static final byte[] DATA = new byte[DATA_SIZE];
+ static {
+ for (int i = 0; i < DATA_SIZE; i++) {
+ DATA[i] = (byte)i;
+ }
+ }
+
+ private static final int LARGE_DATA_SIZE = 256 * 1024;
+ private static final byte[] LARGE_DATA = new byte[LARGE_DATA_SIZE];
+ static {
+ for (int i = 0; i < LARGE_DATA_SIZE; i++) {
+ LARGE_DATA[i] = (byte)i;
+ }
+ }
+
+ private static final ByteBuffer SMALL_BUFFER = ByteBuffer.wrap(DATA);
+ private static final ByteBuffer SMALL_DIRECT_BUFFER = ByteBuffer.allocateDirect(DATA_SIZE);
+ static {
+ SMALL_DIRECT_BUFFER.put(DATA);
+ SMALL_DIRECT_BUFFER.flip();
+ }
+
+ private static final ByteBuffer LARGE_BUFFER = ByteBuffer.wrap(LARGE_DATA);
+ private static final ByteBuffer LARGE_DIRECT_BUFFER =
+ ByteBuffer.allocateDirect(LARGE_DATA_SIZE);
+ static {
+ LARGE_DIRECT_BUFFER.put(LARGE_DATA);
+ LARGE_DIRECT_BUFFER.flip();
+ }
+
+ @Param private Algorithm algorithm;
+
+ public enum Algorithm { MD5, SHA1, SHA256, SHA384, SHA512 };
+
+ @Param private Provider provider;
+
+ public enum Provider { AndroidOpenSSL, BC };
+
+ public void time(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ digest.update(DATA, 0, DATA_SIZE);
+ digest.digest();
+ }
+ }
+
+ public void timeLargeArray(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ digest.update(LARGE_DATA, 0, LARGE_DATA_SIZE);
+ digest.digest();
+ }
+ }
+
+ public void timeSmallChunkOfLargeArray(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ digest.update(LARGE_DATA, LARGE_DATA_SIZE / 2, DATA_SIZE);
+ digest.digest();
+ }
+ }
+
+ public void timeSmallByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ SMALL_BUFFER.position(0);
+ SMALL_BUFFER.limit(SMALL_BUFFER.capacity());
+ digest.update(SMALL_BUFFER);
+ digest.digest();
+ }
+ }
+
+ public void timeSmallDirectByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ SMALL_DIRECT_BUFFER.position(0);
+ SMALL_DIRECT_BUFFER.limit(SMALL_DIRECT_BUFFER.capacity());
+ digest.update(SMALL_DIRECT_BUFFER);
+ digest.digest();
+ }
+ }
+
+ public void timeLargeByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ LARGE_BUFFER.position(0);
+ LARGE_BUFFER.limit(LARGE_BUFFER.capacity());
+ digest.update(LARGE_BUFFER);
+ digest.digest();
+ }
+ }
+
+ public void timeLargeDirectByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ LARGE_DIRECT_BUFFER.position(0);
+ LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.capacity());
+ digest.update(LARGE_DIRECT_BUFFER);
+ digest.digest();
+ }
+ }
+
+ public void timeSmallChunkOfLargeByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ LARGE_BUFFER.position(LARGE_BUFFER.capacity() / 2);
+ LARGE_BUFFER.limit(LARGE_BUFFER.position() + DATA_SIZE);
+ digest.update(LARGE_BUFFER);
+ digest.digest();
+ }
+ }
+
+ public void timeSmallChunkOfLargeDirectByteBuffer(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ MessageDigest digest = MessageDigest.getInstance(algorithm.toString(),
+ provider.toString());
+ LARGE_DIRECT_BUFFER.position(LARGE_DIRECT_BUFFER.capacity() / 2);
+ LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.position() + DATA_SIZE);
+ digest.update(LARGE_DIRECT_BUFFER);
+ digest.digest();
+ }
+ }
+}
diff --git a/benchmarks/regression/MutableIntBenchmark.java b/benchmarks/regression/MutableIntBenchmark.java
new file mode 100644
index 0000000..9e7f893
--- /dev/null
+++ b/benchmarks/regression/MutableIntBenchmark.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public final class MutableIntBenchmark {
+
+ enum Kind {
+ ARRAY() {
+ int[] value = new int[1];
+
+ @Override void timeCreate(int reps) {
+ for (int i = 0; i < reps; i++) {
+ value = new int[] { 5 };
+ }
+ }
+ @Override void timeIncrement(int reps) {
+ for (int i = 0; i < reps; i++) {
+ value[0]++;
+ }
+ }
+ @Override int timeGet(int reps) {
+ int sum = 0;
+ for (int i = 0; i < reps; i++) {
+ sum += value[0];
+ }
+ return sum;
+ }
+ },
+ ATOMIC() {
+ AtomicInteger value = new AtomicInteger();
+
+ @Override void timeCreate(int reps) {
+ for (int i = 0; i < reps; i++) {
+ value = new AtomicInteger(5);
+ }
+ }
+ @Override void timeIncrement(int reps) {
+ for (int i = 0; i < reps; i++) {
+ value.incrementAndGet();
+ }
+ }
+ @Override int timeGet(int reps) {
+ int sum = 0;
+ for (int i = 0; i < reps; i++) {
+ sum += value.intValue();
+ }
+ return sum;
+ }
+ };
+
+ abstract void timeCreate(int reps);
+ abstract void timeIncrement(int reps);
+ abstract int timeGet(int reps);
+ }
+
+ @Param Kind kind;
+
+ public void timeCreate(int reps) {
+ kind.timeCreate(reps);
+ }
+
+ public void timeIncrement(int reps) {
+ kind.timeIncrement(reps);
+ }
+
+ public void timeGet(int reps) {
+ kind.timeGet(reps);
+ }
+}
diff --git a/benchmarks/regression/NumberFormatBenchmark.java b/benchmarks/regression/NumberFormatBenchmark.java
new file mode 100644
index 0000000..4e1f433
--- /dev/null
+++ b/benchmarks/regression/NumberFormatBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+
+public class NumberFormatBenchmark {
+
+ private static Locale locale = Locale.getDefault(Locale.Category.FORMAT);
+
+ public void time_instantiation(int reps) {
+ for (int i = 0; i < reps; i++) {
+ NumberFormat.getInstance(locale);
+ }
+ }
+}
diff --git a/benchmarks/regression/PriorityQueueBenchmark.java b/benchmarks/regression/PriorityQueueBenchmark.java
new file mode 100644
index 0000000..5b80785
--- /dev/null
+++ b/benchmarks/regression/PriorityQueueBenchmark.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.PriorityQueue;
+import java.util.Random;
+
+public class PriorityQueueBenchmark {
+ @Param({"100", "1000", "10000"}) private int queueSize;
+ @Param({"0", "25", "50", "75", "100"}) private int hitRate;
+
+ private PriorityQueue<Integer> pq;
+ private PriorityQueue<Integer> usepq;
+ private List<Integer> seekElements;
+ private Random random = new Random(189279387L);
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ pq = new PriorityQueue<Integer>();
+ usepq = new PriorityQueue<Integer>();
+ seekElements = new ArrayList<Integer>();
+ List<Integer> allElements = new ArrayList<Integer>();
+ int numShared = (int)(queueSize * ((double)hitRate / 100));
+ // the total number of elements we require to engineer a hit rate of hitRate%
+ int totalElements = 2 * queueSize - numShared;
+ for (int i = 0; i < totalElements; i++) {
+ allElements.add(i);
+ }
+ // shuffle these elements so that we get a reasonable distribution of missed elements
+ Collections.shuffle(allElements, random);
+ // add shared elements
+ for (int i = 0; i < numShared; i++) {
+ pq.add(allElements.get(i));
+ seekElements.add(allElements.get(i));
+ }
+ // add priority queue only elements (these won't be touched)
+ for (int i = numShared; i < queueSize; i++) {
+ pq.add(allElements.get(i));
+ }
+ // add non-priority queue elements (these will be misses)
+ for (int i = queueSize; i < totalElements; i++) {
+ seekElements.add(allElements.get(i));
+ }
+ usepq = new PriorityQueue<Integer>(pq);
+ // shuffle again so that elements are accessed in a different pattern than they were
+ // inserted
+ Collections.shuffle(seekElements, random);
+ }
+
+ public boolean timeRemove(int reps) {
+ boolean fake = false;
+ int elementsSize = seekElements.size();
+ // At most allow the queue to empty 10%.
+ int resizingThreshold = queueSize / 10;
+ for (int i = 0; i < reps; i++) {
+ // Reset queue every so often. This will be called more often for smaller
+ // queueSizes, but since a copy is linear, it will also cost proportionally
+ // less, and hopefully it will approximately balance out.
+ if (i % resizingThreshold == 0) {
+ usepq = new PriorityQueue<Integer>(pq);
+ }
+ fake = usepq.remove(seekElements.get(i % elementsSize));
+ }
+ return fake;
+ }
+}
diff --git a/benchmarks/regression/PropertyAccessBenchmark.java b/benchmarks/regression/PropertyAccessBenchmark.java
new file mode 100644
index 0000000..2781a29
--- /dev/null
+++ b/benchmarks/regression/PropertyAccessBenchmark.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public final class PropertyAccessBenchmark {
+ private View view = new View();
+ private Method setX;
+ private GeneratedProperty generatedSetter = new GeneratedSetter();
+ private GeneratedProperty generatedField = new GeneratedField();
+ private Field x;
+ private Object[] argsBox = new Object[1];
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ setX = View.class.getDeclaredMethod("setX", float.class);
+ x = View.class.getDeclaredField("x");
+ }
+
+ public void timeDirectSetter(int reps) {
+ for (int i = 0; i < reps; i++) {
+ view.setX(0.1f);
+ }
+ }
+
+ public void timeDirectFieldSet(int reps) {
+ for (int i = 0; i < reps; i++) {
+ view.x = 0.1f;
+ }
+ }
+
+ public void timeDirectSetterAndBoxing(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Float value = 0.1f;
+ view.setX(value);
+ }
+ }
+
+ public void timeDirectFieldSetAndBoxing(int reps) {
+ for (int i = 0; i < reps; i++) {
+ Float value = 0.1f;
+ view.x = value;
+ }
+ }
+
+ public void timeReflectionSetterAndTwoBoxes(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ setX.invoke(view, 0.1f);
+ }
+ }
+
+ public void timeReflectionSetterAndOneBox(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ argsBox[0] = 0.1f;
+ setX.invoke(view, argsBox);
+ }
+ }
+
+ public void timeReflectionFieldSet(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ x.setFloat(view, 0.1f);
+ }
+ }
+
+ public void timeGeneratedSetter(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ generatedSetter.setFloat(view, 0.1f);
+ }
+ }
+
+ public void timeGeneratedFieldSet(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ generatedField.setFloat(view, 0.1f);
+ }
+ }
+
+ static class View {
+ float x;
+
+ public void setX(float x) {
+ this.x = x;
+ }
+ }
+
+ static interface GeneratedProperty {
+ void setFloat(View v, float f);
+ }
+
+ static class GeneratedSetter implements GeneratedProperty {
+ public void setFloat(View v, float f) {
+ v.setX(f);
+ }
+ }
+
+ static class GeneratedField implements GeneratedProperty {
+ public void setFloat(View v, float f) {
+ v.x = f;
+ }
+ }
+}
diff --git a/benchmarks/regression/ProviderBenchmark.java b/benchmarks/regression/ProviderBenchmark.java
new file mode 100644
index 0000000..cfbd642
--- /dev/null
+++ b/benchmarks/regression/ProviderBenchmark.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.security.Provider;
+import java.security.Security;
+import javax.crypto.Cipher;
+
+public class ProviderBenchmark {
+ public void timeStableProviders(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Cipher c = Cipher.getInstance("RSA");
+ }
+ }
+
+ public void timeWithNewProvider(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Security.addProvider(new MockProvider());
+ try {
+ Cipher c = Cipher.getInstance("RSA");
+ } finally {
+ Security.removeProvider("Mock");
+ }
+ }
+ }
+
+ private static class MockProvider extends Provider {
+ public MockProvider() {
+ super("Mock", 1.0, "Mock me!");
+ }
+ }
+}
diff --git a/benchmarks/regression/R.java b/benchmarks/regression/R.java
new file mode 100644
index 0000000..b5ae3ec
--- /dev/null
+++ b/benchmarks/regression/R.java
@@ -0,0 +1,2540 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+/**
+ * This file is a subset of the frameworks' R.java (resource definition) file
+ * with references to android specific annotations stripped out.
+ */
+public final class R {
+ private R() {}
+
+ public final int mabsListViewStyle = 0;
+ public final int maccessibilityEventTypes = 0;
+ public final int maccessibilityFeedbackType = 0;
+ public final int maccessibilityFlags = 0;
+ public final int maccessibilityLiveRegion = 0;
+ public final int maccessibilityTraversalAfter = 0;
+ public final int maccessibilityTraversalBefore = 0;
+ public final int maccountPreferences = 0;
+ public final int maccountType = 0;
+ public final int maction = 0;
+ public final int mactionBarDivider = 0;
+ public final int mactionBarItemBackground = 0;
+ public final int mactionBarPopupTheme = 0;
+ public final int mactionBarSize = 0;
+ public final int mactionBarSplitStyle = 0;
+ public final int mactionBarStyle = 0;
+ public final int mactionBarTabBarStyle = 0;
+ public final int mactionBarTabStyle = 0;
+ public final int mactionBarTabTextStyle = 0;
+ public final int mactionBarTheme = 0;
+ public final int mactionBarWidgetTheme = 0;
+ public final int mactionButtonStyle = 0;
+ public final int mactionDropDownStyle = 0;
+ public final int mactionLayout = 0;
+ public final int mactionMenuTextAppearance = 0;
+ public final int mactionMenuTextColor = 0;
+ public final int mactionModeBackground = 0;
+ public final int mactionModeCloseButtonStyle = 0;
+ public final int mactionModeCloseDrawable = 0;
+ public final int mactionModeCopyDrawable = 0;
+ public final int mactionModeCutDrawable = 0;
+ public final int mactionModeFindDrawable = 0;
+ public final int mactionModePasteDrawable = 0;
+ public final int mactionModeSelectAllDrawable = 0;
+ public final int mactionModeShareDrawable = 0;
+ public final int mactionModeSplitBackground = 0;
+ public final int mactionModeStyle = 0;
+ public final int mactionModeWebSearchDrawable = 0;
+ public final int mactionOverflowButtonStyle = 0;
+ public final int mactionOverflowMenuStyle = 0;
+ public final int mactionProviderClass = 0;
+ public final int mactionViewClass = 0;
+ public final int mactivatedBackgroundIndicator = 0;
+ public final int mactivityCloseEnterAnimation = 0;
+ public final int mactivityCloseExitAnimation = 0;
+ public final int mactivityOpenEnterAnimation = 0;
+ public final int mactivityOpenExitAnimation = 0;
+ public final int maddPrintersActivity = 0;
+ public final int maddStatesFromChildren = 0;
+ public final int madjustViewBounds = 0;
+ public final int madvancedPrintOptionsActivity = 0;
+ public final int malertDialogIcon = 0;
+ public final int malertDialogStyle = 0;
+ public final int malertDialogTheme = 0;
+ public final int malignmentMode = 0;
+ public final int mallContactsName = 0;
+ public final int mallowBackup = 0;
+ public final int mallowClearUserData = 0;
+ public final int mallowEmbedded = 0;
+ public final int mallowParallelSyncs = 0;
+ public final int mallowSingleTap = 0;
+ public final int mallowTaskReparenting = 0;
+ public final int malpha = 0;
+ public final int malphabeticShortcut = 0;
+ public final int malwaysDrawnWithCache = 0;
+ public final int malwaysRetainTaskState = 0;
+ public final int mamPmBackgroundColor = 0;
+ public final int mamPmTextColor = 0;
+ public final int mambientShadowAlpha = 0;
+ public final int mangle = 0;
+ public final int manimateFirstView = 0;
+ public final int manimateLayoutChanges = 0;
+ public final int manimateOnClick = 0;
+ public final int manimation = 0;
+ public final int manimationCache = 0;
+ public final int manimationDuration = 0;
+ public final int manimationOrder = 0;
+ public final int manimationResolution = 0;
+ public final int mantialias = 0;
+ public final int manyDensity = 0;
+ public final int mapduServiceBanner = 0;
+ public final int mapiKey = 0;
+ public final int mauthor = 0;
+ public final int mauthorities = 0;
+ public final int mautoAdvanceViewId = 0;
+ public final int mautoCompleteTextViewStyle = 0;
+ public final int mautoLink = 0;
+ public final int mautoMirrored = 0;
+ public final int mautoRemoveFromRecents = 0;
+ public final int mautoStart = 0;
+ public final int mautoText = 0;
+ public final int mautoUrlDetect = 0;
+ public final int mbackground = 0;
+ public final int mbackgroundDimAmount = 0;
+ public final int mbackgroundDimEnabled = 0;
+ public final int mbackgroundSplit = 0;
+ public final int mbackgroundStacked = 0;
+ public final int mbackgroundTint = 0;
+ public final int mbackgroundTintMode = 0;
+ public final int mbackupAgent = 0;
+ public final int mbanner = 0;
+ public final int mbaseline = 0;
+ public final int mbaselineAlignBottom = 0;
+ public final int mbaselineAligned = 0;
+ public final int mbaselineAlignedChildIndex = 0;
+ public final int mborderlessButtonStyle = 0;
+ public final int mbottom = 0;
+ public final int mbottomBright = 0;
+ public final int mbottomDark = 0;
+ public final int mbottomLeftRadius = 0;
+ public final int mbottomMedium = 0;
+ public final int mbottomOffset = 0;
+ public final int mbottomRightRadius = 0;
+ public final int mbreadCrumbShortTitle = 0;
+ public final int mbreadCrumbTitle = 0;
+ public final int mbufferType = 0;
+ public final int mbutton = 0;
+ public final int mbuttonBarButtonStyle = 0;
+ public final int mbuttonBarNegativeButtonStyle = 0;
+ public final int mbuttonBarNeutralButtonStyle = 0;
+ public final int mbuttonBarPositiveButtonStyle = 0;
+ public final int mbuttonBarStyle = 0;
+ public final int mbuttonStyle = 0;
+ public final int mbuttonStyleInset = 0;
+ public final int mbuttonStyleSmall = 0;
+ public final int mbuttonStyleToggle = 0;
+ public final int mbuttonTint = 0;
+ public final int mbuttonTintMode = 0;
+ public final int mcacheColorHint = 0;
+ public final int mcalendarTextColor = 0;
+ public final int mcalendarViewShown = 0;
+ public final int mcalendarViewStyle = 0;
+ public final int mcanRequestEnhancedWebAccessibility = 0;
+ public final int mcanRequestFilterKeyEvents = 0;
+ public final int mcanRequestTouchExplorationMode = 0;
+ public final int mcanRetrieveWindowContent = 0;
+ public final int mcandidatesTextStyleSpans = 0;
+ public final int mcapitalize = 0;
+ public final int mcategory = 0;
+ public final int mcenterBright = 0;
+ public final int mcenterColor = 0;
+ public final int mcenterDark = 0;
+ public final int mcenterMedium = 0;
+ public final int mcenterX = 0;
+ public final int mcenterY = 0;
+ public final int mcheckBoxPreferenceStyle = 0;
+ public final int mcheckMark = 0;
+ public final int mcheckMarkTint = 0;
+ public final int mcheckMarkTintMode = 0;
+ public final int mcheckable = 0;
+ public final int mcheckableBehavior = 0;
+ public final int mcheckboxStyle = 0;
+ public final int mchecked = 0;
+ public final int mcheckedButton = 0;
+ public final int mcheckedTextViewStyle = 0;
+ public final int mchildDivider = 0;
+ public final int mchildIndicator = 0;
+ public final int mchildIndicatorEnd = 0;
+ public final int mchildIndicatorLeft = 0;
+ public final int mchildIndicatorRight = 0;
+ public final int mchildIndicatorStart = 0;
+ public final int mchoiceMode = 0;
+ public final int mclearTaskOnLaunch = 0;
+ public final int mclickable = 0;
+ public final int mclipChildren = 0;
+ public final int mclipOrientation = 0;
+ public final int mclipToPadding = 0;
+ public final int mcloseIcon = 0;
+ public final int mcodes = 0;
+ public final int mcollapseColumns = 0;
+ public final int mcollapseContentDescription = 0;
+ public final int mcolor = 0;
+ public final int mcolorAccent = 0;
+ public final int mcolorActivatedHighlight = 0;
+ public final int mcolorBackground = 0;
+ public final int mcolorBackgroundCacheHint = 0;
+ public final int mcolorButtonNormal = 0;
+ public final int mcolorControlActivated = 0;
+ public final int mcolorControlHighlight = 0;
+ public final int mcolorControlNormal = 0;
+ public final int mcolorEdgeEffect = 0;
+ public final int mcolorFocusedHighlight = 0;
+ public final int mcolorForeground = 0;
+ public final int mcolorForegroundInverse = 0;
+ public final int mcolorLongPressedHighlight = 0;
+ public final int mcolorMultiSelectHighlight = 0;
+ public final int mcolorPressedHighlight = 0;
+ public final int mcolorPrimary = 0;
+ public final int mcolorPrimaryDark = 0;
+ public final int mcolumnCount = 0;
+ public final int mcolumnDelay = 0;
+ public final int mcolumnOrderPreserved = 0;
+ public final int mcolumnWidth = 0;
+ public final int mcommitIcon = 0;
+ public final int mcompatibleWidthLimitDp = 0;
+ public final int mcompletionHint = 0;
+ public final int mcompletionHintView = 0;
+ public final int mcompletionThreshold = 0;
+ public final int mconfigChanges = 0;
+ public final int mconfigure = 0;
+ public final int mconstantSize = 0;
+ public final int mcontent = 0;
+ public final int mcontentAgeHint = 0;
+ public final int mcontentAuthority = 0;
+ public final int mcontentDescription = 0;
+ public final int mcontentInsetEnd = 0;
+ public final int mcontentInsetLeft = 0;
+ public final int mcontentInsetRight = 0;
+ public final int mcontentInsetStart = 0;
+ public final int mcontrolX1 = 0;
+ public final int mcontrolX2 = 0;
+ public final int mcontrolY1 = 0;
+ public final int mcontrolY2 = 0;
+ public final int mcountry = 0;
+ public final int mcropToPadding = 0;
+ public final int mcursorVisible = 0;
+ public final int mcustomNavigationLayout = 0;
+ public final int mcustomTokens = 0;
+ public final int mcycles = 0;
+ public final int mdashGap = 0;
+ public final int mdashWidth = 0;
+ public final int mdata = 0;
+ public final int mdatePickerDialogTheme = 0;
+ public final int mdatePickerMode = 0;
+ public final int mdatePickerStyle = 0;
+ public final int mdateTextAppearance = 0;
+ public final int mdayOfWeekBackground = 0;
+ public final int mdayOfWeekTextAppearance = 0;
+ public final int mdebuggable = 0;
+ public final int mdefaultValue = 0;
+ public final int mdelay = 0;
+ public final int mdependency = 0;
+ public final int mdescendantFocusability = 0;
+ public final int mdescription = 0;
+ public final int mdetachWallpaper = 0;
+ public final int mdetailColumn = 0;
+ public final int mdetailSocialSummary = 0;
+ public final int mdetailsElementBackground = 0;
+ public final int mdial = 0;
+ public final int mdialogIcon = 0;
+ public final int mdialogLayout = 0;
+ public final int mdialogMessage = 0;
+ public final int mdialogPreferenceStyle = 0;
+ public final int mdialogPreferredPadding = 0;
+ public final int mdialogTheme = 0;
+ public final int mdialogTitle = 0;
+ public final int mdigits = 0;
+ public final int mdirection = 0;
+ public final int mdirectionDescriptions = 0;
+ public final int mdirectionPriority = 0;
+ public final int mdisableDependentsState = 0;
+ public final int mdisabledAlpha = 0;
+ public final int mdisplayOptions = 0;
+ public final int mdither = 0;
+ public final int mdivider = 0;
+ public final int mdividerHeight = 0;
+ public final int mdividerHorizontal = 0;
+ public final int mdividerPadding = 0;
+ public final int mdividerVertical = 0;
+ public final int mdocumentLaunchMode = 0;
+ public final int mdrawSelectorOnTop = 0;
+ public final int mdrawable = 0;
+ public final int mdrawableBottom = 0;
+ public final int mdrawableEnd = 0;
+ public final int mdrawableLeft = 0;
+ public final int mdrawablePadding = 0;
+ public final int mdrawableRight = 0;
+ public final int mdrawableStart = 0;
+ public final int mdrawableTop = 0;
+ public final int mdrawingCacheQuality = 0;
+ public final int mdropDownAnchor = 0;
+ public final int mdropDownHeight = 0;
+ public final int mdropDownHintAppearance = 0;
+ public final int mdropDownHorizontalOffset = 0;
+ public final int mdropDownItemStyle = 0;
+ public final int mdropDownListViewStyle = 0;
+ public final int mdropDownSelector = 0;
+ public final int mdropDownSpinnerStyle = 0;
+ public final int mdropDownVerticalOffset = 0;
+ public final int mdropDownWidth = 0;
+ public final int mduplicateParentState = 0;
+ public final int mduration = 0;
+ public final int meditTextBackground = 0;
+ public final int meditTextColor = 0;
+ public final int meditTextPreferenceStyle = 0;
+ public final int meditTextStyle = 0;
+ public final int meditable = 0;
+ public final int meditorExtras = 0;
+ public final int melegantTextHeight = 0;
+ public final int melevation = 0;
+ public final int mellipsize = 0;
+ public final int mems = 0;
+ public final int menabled = 0;
+ public final int mendColor = 0;
+ public final int mendYear = 0;
+ public final int menterFadeDuration = 0;
+ public final int mentries = 0;
+ public final int mentryValues = 0;
+ public final int meventsInterceptionEnabled = 0;
+ public final int mexcludeClass = 0;
+ public final int mexcludeFromRecents = 0;
+ public final int mexcludeId = 0;
+ public final int mexcludeName = 0;
+ public final int mexitFadeDuration = 0;
+ public final int mexpandableListPreferredChildIndicatorLeft = 0;
+ public final int mexpandableListPreferredChildIndicatorRight = 0;
+ public final int mexpandableListPreferredChildPaddingLeft = 0;
+ public final int mexpandableListPreferredItemIndicatorLeft = 0;
+ public final int mexpandableListPreferredItemIndicatorRight = 0;
+ public final int mexpandableListPreferredItemPaddingLeft = 0;
+ public final int mexpandableListViewStyle = 0;
+ public final int mexpandableListViewWhiteStyle = 0;
+ public final int mexported = 0;
+ public final int mextraTension = 0;
+ public final int mfactor = 0;
+ public final int mfadeDuration = 0;
+ public final int mfadeEnabled = 0;
+ public final int mfadeOffset = 0;
+ public final int mfadeScrollbars = 0;
+ public final int mfadingEdge = 0;
+ public final int mfadingEdgeLength = 0;
+ public final int mfadingMode = 0;
+ public final int mfastScrollAlwaysVisible = 0;
+ public final int mfastScrollEnabled = 0;
+ public final int mfastScrollOverlayPosition = 0;
+ public final int mfastScrollPreviewBackgroundLeft = 0;
+ public final int mfastScrollPreviewBackgroundRight = 0;
+ public final int mfastScrollStyle = 0;
+ public final int mfastScrollTextColor = 0;
+ public final int mfastScrollThumbDrawable = 0;
+ public final int mfastScrollTrackDrawable = 0;
+ public final int mfillAfter = 0;
+ public final int mfillAlpha = 0;
+ public final int mfillBefore = 0;
+ public final int mfillColor = 0;
+ public final int mfillEnabled = 0;
+ public final int mfillViewport = 0;
+ public final int mfilter = 0;
+ public final int mfilterTouchesWhenObscured = 0;
+ public final int mfinishOnCloseSystemDialogs = 0;
+ public final int mfinishOnTaskLaunch = 0;
+ public final int mfirstDayOfWeek = 0;
+ public final int mfitsSystemWindows = 0;
+ public final int mflipInterval = 0;
+ public final int mfocusable = 0;
+ public final int mfocusableInTouchMode = 0;
+ public final int mfocusedMonthDateColor = 0;
+ public final int mfontFamily = 0;
+ public final int mfontFeatureSettings = 0;
+ public final int mfooterDividersEnabled = 0;
+ public final int mforeground = 0;
+ public final int mforegroundGravity = 0;
+ public final int mforegroundTint = 0;
+ public final int mforegroundTintMode = 0;
+ public final int mformat = 0;
+ public final int mformat12Hour = 0;
+ public final int mformat24Hour = 0;
+ public final int mfragment = 0;
+ public final int mfragmentAllowEnterTransitionOverlap = 0;
+ public final int mfragmentAllowReturnTransitionOverlap = 0;
+ public final int mfragmentCloseEnterAnimation = 0;
+ public final int mfragmentCloseExitAnimation = 0;
+ public final int mfragmentEnterTransition = 0;
+ public final int mfragmentExitTransition = 0;
+ public final int mfragmentFadeEnterAnimation = 0;
+ public final int mfragmentFadeExitAnimation = 0;
+ public final int mfragmentOpenEnterAnimation = 0;
+ public final int mfragmentOpenExitAnimation = 0;
+ public final int mfragmentReenterTransition = 0;
+ public final int mfragmentReturnTransition = 0;
+ public final int mfragmentSharedElementEnterTransition = 0;
+ public final int mfragmentSharedElementReturnTransition = 0;
+ public final int mfreezesText = 0;
+ public final int mfromAlpha = 0;
+ public final int mfromDegrees = 0;
+ public final int mfromId = 0;
+ public final int mfromScene = 0;
+ public final int mfromXDelta = 0;
+ public final int mfromXScale = 0;
+ public final int mfromYDelta = 0;
+ public final int mfromYScale = 0;
+ public final int mfullBackupOnly = 0;
+ public final int mfullBright = 0;
+ public final int mfullDark = 0;
+ public final int mfunctionalTest = 0;
+ public final int mgalleryItemBackground = 0;
+ public final int mgalleryStyle = 0;
+ public final int mgestureColor = 0;
+ public final int mgestureStrokeAngleThreshold = 0;
+ public final int mgestureStrokeLengthThreshold = 0;
+ public final int mgestureStrokeSquarenessThreshold = 0;
+ public final int mgestureStrokeType = 0;
+ public final int mgestureStrokeWidth = 0;
+ public final int mglEsVersion = 0;
+ public final int mgoIcon = 0;
+ public final int mgradientRadius = 0;
+ public final int mgrantUriPermissions = 0;
+ public final int mgravity = 0;
+ public final int mgridViewStyle = 0;
+ public final int mgroupIndicator = 0;
+ public final int mhand_hour = 0;
+ public final int mhand_minute = 0;
+ public final int mhandle = 0;
+ public final int mhandleProfiling = 0;
+ public final int mhapticFeedbackEnabled = 0;
+ public final int mhardwareAccelerated = 0;
+ public final int mhasCode = 0;
+ public final int mheaderAmPmTextAppearance = 0;
+ public final int mheaderBackground = 0;
+ public final int mheaderDayOfMonthTextAppearance = 0;
+ public final int mheaderDividersEnabled = 0;
+ public final int mheaderMonthTextAppearance = 0;
+ public final int mheaderTimeTextAppearance = 0;
+ public final int mheaderYearTextAppearance = 0;
+ public final int mheight = 0;
+ public final int mhideOnContentScroll = 0;
+ public final int mhint = 0;
+ public final int mhomeAsUpIndicator = 0;
+ public final int mhomeLayout = 0;
+ public final int mhorizontalDivider = 0;
+ public final int mhorizontalGap = 0;
+ public final int mhorizontalScrollViewStyle = 0;
+ public final int mhorizontalSpacing = 0;
+ public final int mhost = 0;
+ public final int micon = 0;
+ public final int miconPreview = 0;
+ public final int miconifiedByDefault = 0;
+ public final int mid = 0;
+ public final int mignoreGravity = 0;
+ public final int mimageButtonStyle = 0;
+ public final int mimageWellStyle = 0;
+ public final int mimeActionId = 0;
+ public final int mimeActionLabel = 0;
+ public final int mimeExtractEnterAnimation = 0;
+ public final int mimeExtractExitAnimation = 0;
+ public final int mimeFullscreenBackground = 0;
+ public final int mimeOptions = 0;
+ public final int mimeSubtypeExtraValue = 0;
+ public final int mimeSubtypeLocale = 0;
+ public final int mimeSubtypeMode = 0;
+ public final int mimmersive = 0;
+ public final int mimportantForAccessibility = 0;
+ public final int minAnimation = 0;
+ public final int mincludeFontPadding = 0;
+ public final int mincludeInGlobalSearch = 0;
+ public final int mindeterminate = 0;
+ public final int mindeterminateBehavior = 0;
+ public final int mindeterminateDrawable = 0;
+ public final int mindeterminateDuration = 0;
+ public final int mindeterminateOnly = 0;
+ public final int mindeterminateProgressStyle = 0;
+ public final int mindeterminateTint = 0;
+ public final int mindeterminateTintMode = 0;
+ public final int mindicatorEnd = 0;
+ public final int mindicatorLeft = 0;
+ public final int mindicatorRight = 0;
+ public final int mindicatorStart = 0;
+ public final int minflatedId = 0;
+ public final int minitOrder = 0;
+ public final int minitialKeyguardLayout = 0;
+ public final int minitialLayout = 0;
+ public final int minnerRadius = 0;
+ public final int minnerRadiusRatio = 0;
+ public final int minputMethod = 0;
+ public final int minputType = 0;
+ public final int minset = 0;
+ public final int minsetBottom = 0;
+ public final int minsetLeft = 0;
+ public final int minsetRight = 0;
+ public final int minsetTop = 0;
+ public final int minstallLocation = 0;
+ public final int minterpolator = 0;
+ public final int misAlwaysSyncable = 0;
+ public final int misAsciiCapable = 0;
+ public final int misAuxiliary = 0;
+ public final int misDefault = 0;
+ public final int misGame = 0;
+ public final int misIndicator = 0;
+ public final int misModifier = 0;
+ public final int misRepeatable = 0;
+ public final int misScrollContainer = 0;
+ public final int misSticky = 0;
+ public final int misolatedProcess = 0;
+ public final int mitemBackground = 0;
+ public final int mitemIconDisabledAlpha = 0;
+ public final int mitemPadding = 0;
+ public final int mitemTextAppearance = 0;
+ public final int mkeepScreenOn = 0;
+ public final int mkey = 0;
+ public final int mkeyBackground = 0;
+ public final int mkeyEdgeFlags = 0;
+ public final int mkeyHeight = 0;
+ public final int mkeyIcon = 0;
+ public final int mkeyLabel = 0;
+ public final int mkeyOutputText = 0;
+ public final int mkeyPreviewHeight = 0;
+ public final int mkeyPreviewLayout = 0;
+ public final int mkeyPreviewOffset = 0;
+ public final int mkeySet = 0;
+ public final int mkeyTextColor = 0;
+ public final int mkeyTextSize = 0;
+ public final int mkeyWidth = 0;
+ public final int mkeyboardLayout = 0;
+ public final int mkeyboardMode = 0;
+ public final int mkeycode = 0;
+ public final int mkillAfterRestore = 0;
+ public final int mlabel = 0;
+ public final int mlabelFor = 0;
+ public final int mlabelTextSize = 0;
+ public final int mlargeHeap = 0;
+ public final int mlargeScreens = 0;
+ public final int mlargestWidthLimitDp = 0;
+ public final int mlaunchMode = 0;
+ public final int mlaunchTaskBehindSourceAnimation = 0;
+ public final int mlaunchTaskBehindTargetAnimation = 0;
+ public final int mlayerType = 0;
+ public final int mlayout = 0;
+ public final int mlayoutAnimation = 0;
+ public final int mlayoutDirection = 0;
+ public final int mlayoutMode = 0;
+ public final int mlayout_above = 0;
+ public final int mlayout_alignBaseline = 0;
+ public final int mlayout_alignBottom = 0;
+ public final int mlayout_alignEnd = 0;
+ public final int mlayout_alignLeft = 0;
+ public final int mlayout_alignParentBottom = 0;
+ public final int mlayout_alignParentEnd = 0;
+ public final int mlayout_alignParentLeft = 0;
+ public final int mlayout_alignParentRight = 0;
+ public final int mlayout_alignParentStart = 0;
+ public final int mlayout_alignParentTop = 0;
+ public final int mlayout_alignRight = 0;
+ public final int mlayout_alignStart = 0;
+ public final int mlayout_alignTop = 0;
+ public final int mlayout_alignWithParentIfMissing = 0;
+ public final int mlayout_below = 0;
+ public final int mlayout_centerHorizontal = 0;
+ public final int mlayout_centerInParent = 0;
+ public final int mlayout_centerVertical = 0;
+ public final int mlayout_column = 0;
+ public final int mlayout_columnSpan = 0;
+ public final int mlayout_columnWeight = 0;
+ public final int mlayout_gravity = 0;
+ public final int mlayout_height = 0;
+ public final int mlayout_margin = 0;
+ public final int mlayout_marginBottom = 0;
+ public final int mlayout_marginEnd = 0;
+ public final int mlayout_marginLeft = 0;
+ public final int mlayout_marginRight = 0;
+ public final int mlayout_marginStart = 0;
+ public final int mlayout_marginTop = 0;
+ public final int mlayout_row = 0;
+ public final int mlayout_rowSpan = 0;
+ public final int mlayout_rowWeight = 0;
+ public final int mlayout_scale = 0;
+ public final int mlayout_span = 0;
+ public final int mlayout_toEndOf = 0;
+ public final int mlayout_toLeftOf = 0;
+ public final int mlayout_toRightOf = 0;
+ public final int mlayout_toStartOf = 0;
+ public final int mlayout_weight = 0;
+ public final int mlayout_width = 0;
+ public final int mlayout_x = 0;
+ public final int mlayout_y = 0;
+ public final int mleft = 0;
+ public final int mletterSpacing = 0;
+ public final int mlineSpacingExtra = 0;
+ public final int mlineSpacingMultiplier = 0;
+ public final int mlines = 0;
+ public final int mlinksClickable = 0;
+ public final int mlistChoiceBackgroundIndicator = 0;
+ public final int mlistChoiceIndicatorMultiple = 0;
+ public final int mlistChoiceIndicatorSingle = 0;
+ public final int mlistDivider = 0;
+ public final int mlistDividerAlertDialog = 0;
+ public final int mlistPopupWindowStyle = 0;
+ public final int mlistPreferredItemHeight = 0;
+ public final int mlistPreferredItemHeightLarge = 0;
+ public final int mlistPreferredItemHeightSmall = 0;
+ public final int mlistPreferredItemPaddingEnd = 0;
+ public final int mlistPreferredItemPaddingLeft = 0;
+ public final int mlistPreferredItemPaddingRight = 0;
+ public final int mlistPreferredItemPaddingStart = 0;
+ public final int mlistSelector = 0;
+ public final int mlistSeparatorTextViewStyle = 0;
+ public final int mlistViewStyle = 0;
+ public final int mlistViewWhiteStyle = 0;
+ public final int mlogo = 0;
+ public final int mlongClickable = 0;
+ public final int mloopViews = 0;
+ public final int mmanageSpaceActivity = 0;
+ public final int mmapViewStyle = 0;
+ public final int mmarqueeRepeatLimit = 0;
+ public final int mmatchOrder = 0;
+ public final int mmax = 0;
+ public final int mmaxDate = 0;
+ public final int mmaxEms = 0;
+ public final int mmaxHeight = 0;
+ public final int mmaxItemsPerRow = 0;
+ public final int mmaxLength = 0;
+ public final int mmaxLevel = 0;
+ public final int mmaxLines = 0;
+ public final int mmaxRecents = 0;
+ public final int mmaxRows = 0;
+ public final int mmaxSdkVersion = 0;
+ public final int mmaxWidth = 0;
+ public final int mmaximumAngle = 0;
+ public final int mmeasureAllChildren = 0;
+ public final int mmeasureWithLargestChild = 0;
+ public final int mmediaRouteButtonStyle = 0;
+ public final int mmediaRouteTypes = 0;
+ public final int mmenuCategory = 0;
+ public final int mmimeType = 0;
+ public final int mminDate = 0;
+ public final int mminEms = 0;
+ public final int mminHeight = 0;
+ public final int mminLevel = 0;
+ public final int mminLines = 0;
+ public final int mminResizeHeight = 0;
+ public final int mminResizeWidth = 0;
+ public final int mminSdkVersion = 0;
+ public final int mminWidth = 0;
+ public final int mminimumHorizontalAngle = 0;
+ public final int mminimumVerticalAngle = 0;
+ public final int mmipMap = 0;
+ public final int mmirrorForRtl = 0;
+ public final int mmode = 0;
+ public final int mmoreIcon = 0;
+ public final int mmultiArch = 0;
+ public final int mmultiprocess = 0;
+ public final int mname = 0;
+ public final int mnavigationBarColor = 0;
+ public final int mnavigationContentDescription = 0;
+ public final int mnavigationIcon = 0;
+ public final int mnavigationMode = 0;
+ public final int mnegativeButtonText = 0;
+ public final int mnestedScrollingEnabled = 0;
+ public final int mnextFocusDown = 0;
+ public final int mnextFocusForward = 0;
+ public final int mnextFocusLeft = 0;
+ public final int mnextFocusRight = 0;
+ public final int mnextFocusUp = 0;
+ public final int mnoHistory = 0;
+ public final int mnormalScreens = 0;
+ public final int mnotificationTimeout = 0;
+ public final int mnumColumns = 0;
+ public final int mnumStars = 0;
+ public final int mnumbersBackgroundColor = 0;
+ public final int mnumbersSelectorColor = 0;
+ public final int mnumbersTextColor = 0;
+ public final int mnumeric = 0;
+ public final int mnumericShortcut = 0;
+ public final int monClick = 0;
+ public final int moneshot = 0;
+ public final int mopacity = 0;
+ public final int morder = 0;
+ public final int morderInCategory = 0;
+ public final int mordering = 0;
+ public final int morderingFromXml = 0;
+ public final int morientation = 0;
+ public final int moutAnimation = 0;
+ public final int moutlineProvider = 0;
+ public final int moverScrollFooter = 0;
+ public final int moverScrollHeader = 0;
+ public final int moverScrollMode = 0;
+ public final int moverlapAnchor = 0;
+ public final int moverridesImplicitlyEnabledSubtype = 0;
+ public final int mpackageNames = 0;
+ public final int mpadding = 0;
+ public final int mpaddingBottom = 0;
+ public final int mpaddingEnd = 0;
+ public final int mpaddingLeft = 0;
+ public final int mpaddingMode = 0;
+ public final int mpaddingRight = 0;
+ public final int mpaddingStart = 0;
+ public final int mpaddingTop = 0;
+ public final int mpanelBackground = 0;
+ public final int mpanelColorBackground = 0;
+ public final int mpanelColorForeground = 0;
+ public final int mpanelFullBackground = 0;
+ public final int mpanelTextAppearance = 0;
+ public final int mparentActivityName = 0;
+ public final int mpassword = 0;
+ public final int mpath = 0;
+ public final int mpathData = 0;
+ public final int mpathPattern = 0;
+ public final int mpathPrefix = 0;
+ public final int mpatternPathData = 0;
+ public final int mpermission = 0;
+ public final int mpermissionFlags = 0;
+ public final int mpermissionGroup = 0;
+ public final int mpermissionGroupFlags = 0;
+ public final int mpersistableMode = 0;
+ public final int mpersistent = 0;
+ public final int mpersistentDrawingCache = 0;
+ public final int mphoneNumber = 0;
+ public final int mpivotX = 0;
+ public final int mpivotY = 0;
+ public final int mpopupAnimationStyle = 0;
+ public final int mpopupBackground = 0;
+ public final int mpopupCharacters = 0;
+ public final int mpopupElevation = 0;
+ public final int mpopupKeyboard = 0;
+ public final int mpopupLayout = 0;
+ public final int mpopupMenuStyle = 0;
+ public final int mpopupTheme = 0;
+ public final int mpopupWindowStyle = 0;
+ public final int mport = 0;
+ public final int mpositiveButtonText = 0;
+ public final int mpreferenceCategoryStyle = 0;
+ public final int mpreferenceInformationStyle = 0;
+ public final int mpreferenceLayoutChild = 0;
+ public final int mpreferenceScreenStyle = 0;
+ public final int mpreferenceStyle = 0;
+ public final int mpresentationTheme = 0;
+ public final int mpreviewImage = 0;
+ public final int mpriority = 0;
+ public final int mprivateImeOptions = 0;
+ public final int mprivate_resource_pad1 = 0;
+ public final int mprivate_resource_pad10 = 0;
+ public final int mprivate_resource_pad11 = 0;
+ public final int mprivate_resource_pad12 = 0;
+ public final int mprivate_resource_pad13 = 0;
+ public final int mprivate_resource_pad14 = 0;
+ public final int mprivate_resource_pad15 = 0;
+ public final int mprivate_resource_pad16 = 0;
+ public final int mprivate_resource_pad17 = 0;
+ public final int mprivate_resource_pad18 = 0;
+ public final int mprivate_resource_pad19 = 0;
+ public final int mprivate_resource_pad2 = 0;
+ public final int mprivate_resource_pad20 = 0;
+ public final int mprivate_resource_pad21 = 0;
+ public final int mprivate_resource_pad22 = 0;
+ public final int mprivate_resource_pad23 = 0;
+ public final int mprivate_resource_pad24 = 0;
+ public final int mprivate_resource_pad25 = 0;
+ public final int mprivate_resource_pad26 = 0;
+ public final int mprivate_resource_pad27 = 0;
+ public final int mprivate_resource_pad28 = 0;
+ public final int mprivate_resource_pad29 = 0;
+ public final int mprivate_resource_pad3 = 0;
+ public final int mprivate_resource_pad30 = 0;
+ public final int mprivate_resource_pad31 = 0;
+ public final int mprivate_resource_pad32 = 0;
+ public final int mprivate_resource_pad33 = 0;
+ public final int mprivate_resource_pad34 = 0;
+ public final int mprivate_resource_pad35 = 0;
+ public final int mprivate_resource_pad36 = 0;
+ public final int mprivate_resource_pad37 = 0;
+ public final int mprivate_resource_pad38 = 0;
+ public final int mprivate_resource_pad39 = 0;
+ public final int mprivate_resource_pad4 = 0;
+ public final int mprivate_resource_pad40 = 0;
+ public final int mprivate_resource_pad41 = 0;
+ public final int mprivate_resource_pad42 = 0;
+ public final int mprivate_resource_pad43 = 0;
+ public final int mprivate_resource_pad44 = 0;
+ public final int mprivate_resource_pad45 = 0;
+ public final int mprivate_resource_pad46 = 0;
+ public final int mprivate_resource_pad47 = 0;
+ public final int mprivate_resource_pad48 = 0;
+ public final int mprivate_resource_pad49 = 0;
+ public final int mprivate_resource_pad5 = 0;
+ public final int mprivate_resource_pad50 = 0;
+ public final int mprivate_resource_pad6 = 0;
+ public final int mprivate_resource_pad7 = 0;
+ public final int mprivate_resource_pad8 = 0;
+ public final int mprivate_resource_pad9 = 0;
+ public final int mprocess = 0;
+ public final int mprogress = 0;
+ public final int mprogressBackgroundTint = 0;
+ public final int mprogressBackgroundTintMode = 0;
+ public final int mprogressBarPadding = 0;
+ public final int mprogressBarStyle = 0;
+ public final int mprogressBarStyleHorizontal = 0;
+ public final int mprogressBarStyleInverse = 0;
+ public final int mprogressBarStyleLarge = 0;
+ public final int mprogressBarStyleLargeInverse = 0;
+ public final int mprogressBarStyleSmall = 0;
+ public final int mprogressBarStyleSmallInverse = 0;
+ public final int mprogressBarStyleSmallTitle = 0;
+ public final int mprogressDrawable = 0;
+ public final int mprogressTint = 0;
+ public final int mprogressTintMode = 0;
+ public final int mprompt = 0;
+ public final int mpropertyName = 0;
+ public final int mpropertyXName = 0;
+ public final int mpropertyYName = 0;
+ public final int mprotectionLevel = 0;
+ public final int mpublicKey = 0;
+ public final int mqueryActionMsg = 0;
+ public final int mqueryAfterZeroResults = 0;
+ public final int mqueryBackground = 0;
+ public final int mqueryHint = 0;
+ public final int mquickContactBadgeStyleSmallWindowLarge = 0;
+ public final int mquickContactBadgeStyleSmallWindowMedium = 0;
+ public final int mquickContactBadgeStyleSmallWindowSmall = 0;
+ public final int mquickContactBadgeStyleWindowLarge = 0;
+ public final int mquickContactBadgeStyleWindowMedium = 0;
+ public final int mquickContactBadgeStyleWindowSmall = 0;
+ public final int mradioButtonStyle = 0;
+ public final int mradius = 0;
+ public final int mrating = 0;
+ public final int mratingBarStyle = 0;
+ public final int mratingBarStyleIndicator = 0;
+ public final int mratingBarStyleSmall = 0;
+ public final int mreadPermission = 0;
+ public final int mrecognitionService = 0;
+ public final int mrelinquishTaskIdentity = 0;
+ public final int mreparent = 0;
+ public final int mreparentWithOverlay = 0;
+ public final int mrepeatCount = 0;
+ public final int mrepeatMode = 0;
+ public final int mreqFiveWayNav = 0;
+ public final int mreqHardKeyboard = 0;
+ public final int mreqKeyboardType = 0;
+ public final int mreqNavigation = 0;
+ public final int mreqTouchScreen = 0;
+ public final int mrequireDeviceUnlock = 0;
+ public final int mrequired = 0;
+ public final int mrequiredAccountType = 0;
+ public final int mrequiredForAllUsers = 0;
+ public final int mrequiresFadingEdge = 0;
+ public final int mrequiresSmallestWidthDp = 0;
+ public final int mresizeClip = 0;
+ public final int mresizeMode = 0;
+ public final int mresizeable = 0;
+ public final int mresource = 0;
+ public final int mrestoreAnyVersion = 0;
+ public final int mrestoreNeedsApplication = 0;
+ public final int mrestrictedAccountType = 0;
+ public final int mrestrictionType = 0;
+ public final int mresumeWhilePausing = 0;
+ public final int mreversible = 0;
+ public final int mright = 0;
+ public final int mringtonePreferenceStyle = 0;
+ public final int mringtoneType = 0;
+ public final int mrotation = 0;
+ public final int mrotationX = 0;
+ public final int mrotationY = 0;
+ public final int mrowCount = 0;
+ public final int mrowDelay = 0;
+ public final int mrowEdgeFlags = 0;
+ public final int mrowHeight = 0;
+ public final int mrowOrderPreserved = 0;
+ public final int msaveEnabled = 0;
+ public final int mscaleGravity = 0;
+ public final int mscaleHeight = 0;
+ public final int mscaleType = 0;
+ public final int mscaleWidth = 0;
+ public final int mscaleX = 0;
+ public final int mscaleY = 0;
+ public final int mscheme = 0;
+ public final int mscreenDensity = 0;
+ public final int mscreenOrientation = 0;
+ public final int mscreenSize = 0;
+ public final int mscrollHorizontally = 0;
+ public final int mscrollViewStyle = 0;
+ public final int mscrollX = 0;
+ public final int mscrollY = 0;
+ public final int mscrollbarAlwaysDrawHorizontalTrack = 0;
+ public final int mscrollbarAlwaysDrawVerticalTrack = 0;
+ public final int mscrollbarDefaultDelayBeforeFade = 0;
+ public final int mscrollbarFadeDuration = 0;
+ public final int mscrollbarSize = 0;
+ public final int mscrollbarStyle = 0;
+ public final int mscrollbarThumbHorizontal = 0;
+ public final int mscrollbarThumbVertical = 0;
+ public final int mscrollbarTrackHorizontal = 0;
+ public final int mscrollbarTrackVertical = 0;
+ public final int mscrollbars = 0;
+ public final int mscrollingCache = 0;
+ public final int msearchButtonText = 0;
+ public final int msearchIcon = 0;
+ public final int msearchKeyphrase = 0;
+ public final int msearchKeyphraseId = 0;
+ public final int msearchKeyphraseRecognitionFlags = 0;
+ public final int msearchKeyphraseSupportedLocales = 0;
+ public final int msearchMode = 0;
+ public final int msearchSettingsDescription = 0;
+ public final int msearchSuggestAuthority = 0;
+ public final int msearchSuggestIntentAction = 0;
+ public final int msearchSuggestIntentData = 0;
+ public final int msearchSuggestPath = 0;
+ public final int msearchSuggestSelection = 0;
+ public final int msearchSuggestThreshold = 0;
+ public final int msearchViewStyle = 0;
+ public final int msecondaryProgress = 0;
+ public final int msecondaryProgressTint = 0;
+ public final int msecondaryProgressTintMode = 0;
+ public final int mseekBarStyle = 0;
+ public final int msegmentedButtonStyle = 0;
+ public final int mselectAllOnFocus = 0;
+ public final int mselectable = 0;
+ public final int mselectableItemBackground = 0;
+ public final int mselectableItemBackgroundBorderless = 0;
+ public final int mselectedDateVerticalBar = 0;
+ public final int mselectedWeekBackgroundColor = 0;
+ public final int msessionService = 0;
+ public final int msettingsActivity = 0;
+ public final int msetupActivity = 0;
+ public final int mshadowColor = 0;
+ public final int mshadowDx = 0;
+ public final int mshadowDy = 0;
+ public final int mshadowRadius = 0;
+ public final int mshape = 0;
+ public final int mshareInterpolator = 0;
+ public final int msharedUserId = 0;
+ public final int msharedUserLabel = 0;
+ public final int mshouldDisableView = 0;
+ public final int mshowAsAction = 0;
+ public final int mshowDefault = 0;
+ public final int mshowDividers = 0;
+ public final int mshowOnLockScreen = 0;
+ public final int mshowSilent = 0;
+ public final int mshowText = 0;
+ public final int mshowWeekNumber = 0;
+ public final int mshownWeekCount = 0;
+ public final int mshrinkColumns = 0;
+ public final int msingleLine = 0;
+ public final int msingleUser = 0;
+ public final int mslideEdge = 0;
+ public final int msmallIcon = 0;
+ public final int msmallScreens = 0;
+ public final int msmoothScrollbar = 0;
+ public final int msolidColor = 0;
+ public final int msoundEffectsEnabled = 0;
+ public final int mspacing = 0;
+ public final int mspinnerDropDownItemStyle = 0;
+ public final int mspinnerItemStyle = 0;
+ public final int mspinnerMode = 0;
+ public final int mspinnerStyle = 0;
+ public final int mspinnersShown = 0;
+ public final int msplitMotionEvents = 0;
+ public final int msplitTrack = 0;
+ public final int mspotShadowAlpha = 0;
+ public final int msrc = 0;
+ public final int mssp = 0;
+ public final int msspPattern = 0;
+ public final int msspPrefix = 0;
+ public final int mstackFromBottom = 0;
+ public final int mstackViewStyle = 0;
+ public final int mstarStyle = 0;
+ public final int mstartColor = 0;
+ public final int mstartDelay = 0;
+ public final int mstartOffset = 0;
+ public final int mstartYear = 0;
+ public final int mstateListAnimator = 0;
+ public final int mstateNotNeeded = 0;
+ public final int mstate_above_anchor = 0;
+ public final int mstate_accelerated = 0;
+ public final int mstate_activated = 0;
+ public final int mstate_active = 0;
+ public final int mstate_checkable = 0;
+ public final int mstate_checked = 0;
+ public final int mstate_drag_can_accept = 0;
+ public final int mstate_drag_hovered = 0;
+ public final int mstate_empty = 0;
+ public final int mstate_enabled = 0;
+ public final int mstate_expanded = 0;
+ public final int mstate_first = 0;
+ public final int mstate_focused = 0;
+ public final int mstate_hovered = 0;
+ public final int mstate_last = 0;
+ public final int mstate_long_pressable = 0;
+ public final int mstate_middle = 0;
+ public final int mstate_multiline = 0;
+ public final int mstate_pressed = 0;
+ public final int mstate_selected = 0;
+ public final int mstate_single = 0;
+ public final int mstate_window_focused = 0;
+ public final int mstaticWallpaperPreview = 0;
+ public final int mstatusBarColor = 0;
+ public final int mstepSize = 0;
+ public final int mstopWithTask = 0;
+ public final int mstreamType = 0;
+ public final int mstretchColumns = 0;
+ public final int mstretchMode = 0;
+ public final int mstrokeAlpha = 0;
+ public final int mstrokeColor = 0;
+ public final int mstrokeLineCap = 0;
+ public final int mstrokeLineJoin = 0;
+ public final int mstrokeMiterLimit = 0;
+ public final int mstrokeWidth = 0;
+ public final int msubmitBackground = 0;
+ public final int msubtitle = 0;
+ public final int msubtitleTextAppearance = 0;
+ public final int msubtitleTextStyle = 0;
+ public final int msubtypeExtraValue = 0;
+ public final int msubtypeId = 0;
+ public final int msubtypeLocale = 0;
+ public final int msuggestActionMsg = 0;
+ public final int msuggestActionMsgColumn = 0;
+ public final int msuggestionRowLayout = 0;
+ public final int msummary = 0;
+ public final int msummaryColumn = 0;
+ public final int msummaryOff = 0;
+ public final int msummaryOn = 0;
+ public final int msupportsRtl = 0;
+ public final int msupportsSwitchingToNextInputMethod = 0;
+ public final int msupportsUploading = 0;
+ public final int mswitchMinWidth = 0;
+ public final int mswitchPadding = 0;
+ public final int mswitchPreferenceStyle = 0;
+ public final int mswitchStyle = 0;
+ public final int mswitchTextAppearance = 0;
+ public final int mswitchTextOff = 0;
+ public final int mswitchTextOn = 0;
+ public final int msyncable = 0;
+ public final int mtabStripEnabled = 0;
+ public final int mtabStripLeft = 0;
+ public final int mtabStripRight = 0;
+ public final int mtabWidgetStyle = 0;
+ public final int mtag = 0;
+ public final int mtargetActivity = 0;
+ public final int mtargetClass = 0;
+ public final int mtargetDescriptions = 0;
+ public final int mtargetId = 0;
+ public final int mtargetName = 0;
+ public final int mtargetPackage = 0;
+ public final int mtargetSdkVersion = 0;
+ public final int mtaskAffinity = 0;
+ public final int mtaskCloseEnterAnimation = 0;
+ public final int mtaskCloseExitAnimation = 0;
+ public final int mtaskOpenEnterAnimation = 0;
+ public final int mtaskOpenExitAnimation = 0;
+ public final int mtaskToBackEnterAnimation = 0;
+ public final int mtaskToBackExitAnimation = 0;
+ public final int mtaskToFrontEnterAnimation = 0;
+ public final int mtaskToFrontExitAnimation = 0;
+ public final int mtension = 0;
+ public final int mtestOnly = 0;
+ public final int mtext = 0;
+ public final int mtextAlignment = 0;
+ public final int mtextAllCaps = 0;
+ public final int mtextAppearance = 0;
+ public final int mtextAppearanceButton = 0;
+ public final int mtextAppearanceInverse = 0;
+ public final int mtextAppearanceLarge = 0;
+ public final int mtextAppearanceLargeInverse = 0;
+ public final int mtextAppearanceLargePopupMenu = 0;
+ public final int mtextAppearanceListItem = 0;
+ public final int mtextAppearanceListItemSecondary = 0;
+ public final int mtextAppearanceListItemSmall = 0;
+ public final int mtextAppearanceMedium = 0;
+ public final int mtextAppearanceMediumInverse = 0;
+ public final int mtextAppearanceSearchResultSubtitle = 0;
+ public final int mtextAppearanceSearchResultTitle = 0;
+ public final int mtextAppearanceSmall = 0;
+ public final int mtextAppearanceSmallInverse = 0;
+ public final int mtextAppearanceSmallPopupMenu = 0;
+ public final int mtextCheckMark = 0;
+ public final int mtextCheckMarkInverse = 0;
+ public final int mtextColor = 0;
+ public final int mtextColorAlertDialogListItem = 0;
+ public final int mtextColorHighlight = 0;
+ public final int mtextColorHighlightInverse = 0;
+ public final int mtextColorHint = 0;
+ public final int mtextColorHintInverse = 0;
+ public final int mtextColorLink = 0;
+ public final int mtextColorLinkInverse = 0;
+ public final int mtextColorPrimary = 0;
+ public final int mtextColorPrimaryDisableOnly = 0;
+ public final int mtextColorPrimaryInverse = 0;
+ public final int mtextColorPrimaryInverseDisableOnly = 0;
+ public final int mtextColorPrimaryInverseNoDisable = 0;
+ public final int mtextColorPrimaryNoDisable = 0;
+ public final int mtextColorSecondary = 0;
+ public final int mtextColorSecondaryInverse = 0;
+ public final int mtextColorSecondaryInverseNoDisable = 0;
+ public final int mtextColorSecondaryNoDisable = 0;
+ public final int mtextColorTertiary = 0;
+ public final int mtextColorTertiaryInverse = 0;
+ public final int mtextCursorDrawable = 0;
+ public final int mtextDirection = 0;
+ public final int mtextEditNoPasteWindowLayout = 0;
+ public final int mtextEditPasteWindowLayout = 0;
+ public final int mtextEditSideNoPasteWindowLayout = 0;
+ public final int mtextEditSidePasteWindowLayout = 0;
+ public final int mtextEditSuggestionItemLayout = 0;
+ public final int mtextFilterEnabled = 0;
+ public final int mtextIsSelectable = 0;
+ public final int mtextOff = 0;
+ public final int mtextOn = 0;
+ public final int mtextScaleX = 0;
+ public final int mtextSelectHandle = 0;
+ public final int mtextSelectHandleLeft = 0;
+ public final int mtextSelectHandleRight = 0;
+ public final int mtextSelectHandleWindowStyle = 0;
+ public final int mtextSize = 0;
+ public final int mtextStyle = 0;
+ public final int mtextSuggestionsWindowStyle = 0;
+ public final int mtextViewStyle = 0;
+ public final int mtheme = 0;
+ public final int mthickness = 0;
+ public final int mthicknessRatio = 0;
+ public final int mthumb = 0;
+ public final int mthumbOffset = 0;
+ public final int mthumbTextPadding = 0;
+ public final int mthumbTint = 0;
+ public final int mthumbTintMode = 0;
+ public final int mthumbnail = 0;
+ public final int mtileMode = 0;
+ public final int mtileModeX = 0;
+ public final int mtileModeY = 0;
+ public final int mtimePickerDialogTheme = 0;
+ public final int mtimePickerMode = 0;
+ public final int mtimePickerStyle = 0;
+ public final int mtimeZone = 0;
+ public final int mtint = 0;
+ public final int mtintMode = 0;
+ public final int mtitle = 0;
+ public final int mtitleCondensed = 0;
+ public final int mtitleTextAppearance = 0;
+ public final int mtitleTextStyle = 0;
+ public final int mtoAlpha = 0;
+ public final int mtoDegrees = 0;
+ public final int mtoId = 0;
+ public final int mtoScene = 0;
+ public final int mtoXDelta = 0;
+ public final int mtoXScale = 0;
+ public final int mtoYDelta = 0;
+ public final int mtoYScale = 0;
+ public final int mtoolbarStyle = 0;
+ public final int mtop = 0;
+ public final int mtopBright = 0;
+ public final int mtopDark = 0;
+ public final int mtopLeftRadius = 0;
+ public final int mtopOffset = 0;
+ public final int mtopRightRadius = 0;
+ public final int mtouchscreenBlocksFocus = 0;
+ public final int mtrack = 0;
+ public final int mtranscriptMode = 0;
+ public final int mtransformPivotX = 0;
+ public final int mtransformPivotY = 0;
+ public final int mtransition = 0;
+ public final int mtransitionGroup = 0;
+ public final int mtransitionName = 0;
+ public final int mtransitionOrdering = 0;
+ public final int mtransitionVisibilityMode = 0;
+ public final int mtranslateX = 0;
+ public final int mtranslateY = 0;
+ public final int mtranslationX = 0;
+ public final int mtranslationY = 0;
+ public final int mtranslationZ = 0;
+ public final int mtrimPathEnd = 0;
+ public final int mtrimPathOffset = 0;
+ public final int mtrimPathStart = 0;
+ public final int mtype = 0;
+ public final int mtypeface = 0;
+ public final int muiOptions = 0;
+ public final int muncertainGestureColor = 0;
+ public final int munfocusedMonthDateColor = 0;
+ public final int munselectedAlpha = 0;
+ public final int mupdatePeriodMillis = 0;
+ public final int museDefaultMargins = 0;
+ public final int museIntrinsicSizeAsMinimum = 0;
+ public final int museLevel = 0;
+ public final int muserVisible = 0;
+ public final int mvalue = 0;
+ public final int mvalueFrom = 0;
+ public final int mvalueTo = 0;
+ public final int mvalueType = 0;
+ public final int mvariablePadding = 0;
+ public final int mvendor = 0;
+ public final int mversionCode = 0;
+ public final int mversionName = 0;
+ public final int mverticalCorrection = 0;
+ public final int mverticalDivider = 0;
+ public final int mverticalGap = 0;
+ public final int mverticalScrollbarPosition = 0;
+ public final int mverticalSpacing = 0;
+ public final int mviewportHeight = 0;
+ public final int mviewportWidth = 0;
+ public final int mvisibility = 0;
+ public final int mvisible = 0;
+ public final int mvmSafeMode = 0;
+ public final int mvoiceIcon = 0;
+ public final int mvoiceLanguage = 0;
+ public final int mvoiceLanguageModel = 0;
+ public final int mvoiceMaxResults = 0;
+ public final int mvoicePromptText = 0;
+ public final int mvoiceSearchMode = 0;
+ public final int mwallpaperCloseEnterAnimation = 0;
+ public final int mwallpaperCloseExitAnimation = 0;
+ public final int mwallpaperIntraCloseEnterAnimation = 0;
+ public final int mwallpaperIntraCloseExitAnimation = 0;
+ public final int mwallpaperIntraOpenEnterAnimation = 0;
+ public final int mwallpaperIntraOpenExitAnimation = 0;
+ public final int mwallpaperOpenEnterAnimation = 0;
+ public final int mwallpaperOpenExitAnimation = 0;
+ public final int mwebTextViewStyle = 0;
+ public final int mwebViewStyle = 0;
+ public final int mweekDayTextAppearance = 0;
+ public final int mweekNumberColor = 0;
+ public final int mweekSeparatorLineColor = 0;
+ public final int mweightSum = 0;
+ public final int mwidgetCategory = 0;
+ public final int mwidgetLayout = 0;
+ public final int mwidth = 0;
+ public final int mwindowActionBar = 0;
+ public final int mwindowActionBarOverlay = 0;
+ public final int mwindowActionModeOverlay = 0;
+ public final int mwindowActivityTransitions = 0;
+ public final int mwindowAllowEnterTransitionOverlap = 0;
+ public final int mwindowAllowReturnTransitionOverlap = 0;
+ public final int mwindowAnimationStyle = 0;
+ public final int mwindowBackground = 0;
+ public final int mwindowClipToOutline = 0;
+ public final int mwindowCloseOnTouchOutside = 0;
+ public final int mwindowContentOverlay = 0;
+ public final int mwindowContentTransitionManager = 0;
+ public final int mwindowContentTransitions = 0;
+ public final int mwindowDisablePreview = 0;
+ public final int mwindowDrawsSystemBarBackgrounds = 0;
+ public final int mwindowElevation = 0;
+ public final int mwindowEnableSplitTouch = 0;
+ public final int mwindowEnterAnimation = 0;
+ public final int mwindowEnterTransition = 0;
+ public final int mwindowExitAnimation = 0;
+ public final int mwindowExitTransition = 0;
+ public final int mwindowFrame = 0;
+ public final int mwindowFullscreen = 0;
+ public final int mwindowHideAnimation = 0;
+ public final int mwindowIsFloating = 0;
+ public final int mwindowIsTranslucent = 0;
+ public final int mwindowMinWidthMajor = 0;
+ public final int mwindowMinWidthMinor = 0;
+ public final int mwindowNoDisplay = 0;
+ public final int mwindowNoTitle = 0;
+ public final int mwindowOverscan = 0;
+ public final int mwindowReenterTransition = 0;
+ public final int mwindowReturnTransition = 0;
+ public final int mwindowSharedElementEnterTransition = 0;
+ public final int mwindowSharedElementExitTransition = 0;
+ public final int mwindowSharedElementReenterTransition = 0;
+ public final int mwindowSharedElementReturnTransition = 0;
+ public final int mwindowSharedElementsUseOverlay = 0;
+ public final int mwindowShowAnimation = 0;
+ public final int mwindowShowWallpaper = 0;
+ public final int mwindowSoftInputMode = 0;
+ public final int mwindowSwipeToDismiss = 0;
+ public final int mwindowTitleBackgroundStyle = 0;
+ public final int mwindowTitleSize = 0;
+ public final int mwindowTitleStyle = 0;
+ public final int mwindowTransitionBackgroundFadeDuration = 0;
+ public final int mwindowTranslucentNavigation = 0;
+ public final int mwindowTranslucentStatus = 0;
+ public final int mwritePermission = 0;
+ public final int mx = 0;
+ public final int mxlargeScreens = 0;
+ public final int my = 0;
+ public final int myearListItemTextAppearance = 0;
+ public final int myearListSelectorColor = 0;
+ public final int myesNoPreferenceStyle = 0;
+ public final int mzAdjustment = 0;
+
+
+ public static final int absListViewStyle = 0;
+ public static final int accessibilityEventTypes = 0;
+ public static final int accessibilityFeedbackType = 0;
+ public static final int accessibilityFlags = 0;
+ public static final int accessibilityLiveRegion = 0;
+ public static final int accessibilityTraversalAfter = 0;
+ public static final int accessibilityTraversalBefore = 0;
+ public static final int accountPreferences = 0;
+ public static final int accountType = 0;
+ public static final int action = 0;
+ public static final int actionBarDivider = 0;
+ public static final int actionBarItemBackground = 0;
+ public static final int actionBarPopupTheme = 0;
+ public static final int actionBarSize = 0;
+ public static final int actionBarSplitStyle = 0;
+ public static final int actionBarStyle = 0;
+ public static final int actionBarTabBarStyle = 0;
+ public static final int actionBarTabStyle = 0;
+ public static final int actionBarTabTextStyle = 0;
+ public static final int actionBarTheme = 0;
+ public static final int actionBarWidgetTheme = 0;
+ public static final int actionButtonStyle = 0;
+ public static final int actionDropDownStyle = 0;
+ public static final int actionLayout = 0;
+ public static final int actionMenuTextAppearance = 0;
+ public static final int actionMenuTextColor = 0;
+ public static final int actionModeBackground = 0;
+ public static final int actionModeCloseButtonStyle = 0;
+ public static final int actionModeCloseDrawable = 0;
+ public static final int actionModeCopyDrawable = 0;
+ public static final int actionModeCutDrawable = 0;
+ public static final int actionModeFindDrawable = 0;
+ public static final int actionModePasteDrawable = 0;
+ public static final int actionModeSelectAllDrawable = 0;
+ public static final int actionModeShareDrawable = 0;
+ public static final int actionModeSplitBackground = 0;
+ public static final int actionModeStyle = 0;
+ public static final int actionModeWebSearchDrawable = 0;
+ public static final int actionOverflowButtonStyle = 0;
+ public static final int actionOverflowMenuStyle = 0;
+ public static final int actionProviderClass = 0;
+ public static final int actionViewClass = 0;
+ public static final int activatedBackgroundIndicator = 0;
+ public static final int activityCloseEnterAnimation = 0;
+ public static final int activityCloseExitAnimation = 0;
+ public static final int activityOpenEnterAnimation = 0;
+ public static final int activityOpenExitAnimation = 0;
+ public static final int addPrintersActivity = 0;
+ public static final int addStatesFromChildren = 0;
+ public static final int adjustViewBounds = 0;
+ public static final int advancedPrintOptionsActivity = 0;
+ public static final int alertDialogIcon = 0;
+ public static final int alertDialogStyle = 0;
+ public static final int alertDialogTheme = 0;
+ public static final int alignmentMode = 0;
+ public static final int allContactsName = 0;
+ public static final int allowBackup = 0;
+ public static final int allowClearUserData = 0;
+ public static final int allowEmbedded = 0;
+ public static final int allowParallelSyncs = 0;
+ public static final int allowSingleTap = 0;
+ public static final int allowTaskReparenting = 0;
+ public static final int alpha = 0;
+ public static final int alphabeticShortcut = 0;
+ public static final int alwaysDrawnWithCache = 0;
+ public static final int alwaysRetainTaskState = 0;
+ public static final int amPmBackgroundColor = 0;
+ public static final int amPmTextColor = 0;
+ public static final int ambientShadowAlpha = 0;
+ public static final int angle = 0;
+ public static final int animateFirstView = 0;
+ public static final int animateLayoutChanges = 0;
+ public static final int animateOnClick = 0;
+ public static final int animation = 0;
+ public static final int animationCache = 0;
+ public static final int animationDuration = 0;
+ public static final int animationOrder = 0;
+ public static final int animationResolution = 0;
+ public static final int antialias = 0;
+ public static final int anyDensity = 0;
+ public static final int apduServiceBanner = 0;
+ public static final int apiKey = 0;
+ public static final int author = 0;
+ public static final int authorities = 0;
+ public static final int autoAdvanceViewId = 0;
+ public static final int autoCompleteTextViewStyle = 0;
+ public static final int autoLink = 0;
+ public static final int autoMirrored = 0;
+ public static final int autoRemoveFromRecents = 0;
+ public static final int autoStart = 0;
+ public static final int autoText = 0;
+ public static final int autoUrlDetect = 0;
+ public static final int background = 0;
+ public static final int backgroundDimAmount = 0;
+ public static final int backgroundDimEnabled = 0;
+ public static final int backgroundSplit = 0;
+ public static final int backgroundStacked = 0;
+ public static final int backgroundTint = 0;
+ public static final int backgroundTintMode = 0;
+ public static final int backupAgent = 0;
+ public static final int banner = 0;
+ public static final int baseline = 0;
+ public static final int baselineAlignBottom = 0;
+ public static final int baselineAligned = 0;
+ public static final int baselineAlignedChildIndex = 0;
+ public static final int borderlessButtonStyle = 0;
+ public static final int bottom = 0;
+ public static final int bottomBright = 0;
+ public static final int bottomDark = 0;
+ public static final int bottomLeftRadius = 0;
+ public static final int bottomMedium = 0;
+ public static final int bottomOffset = 0;
+ public static final int bottomRightRadius = 0;
+ public static final int breadCrumbShortTitle = 0;
+ public static final int breadCrumbTitle = 0;
+ public static final int bufferType = 0;
+ public static final int button = 0;
+ public static final int buttonBarButtonStyle = 0;
+ public static final int buttonBarNegativeButtonStyle = 0;
+ public static final int buttonBarNeutralButtonStyle = 0;
+ public static final int buttonBarPositiveButtonStyle = 0;
+ public static final int buttonBarStyle = 0;
+ public static final int buttonStyle = 0;
+ public static final int buttonStyleInset = 0;
+ public static final int buttonStyleSmall = 0;
+ public static final int buttonStyleToggle = 0;
+ public static final int buttonTint = 0;
+ public static final int buttonTintMode = 0;
+ public static final int cacheColorHint = 0;
+ public static final int calendarTextColor = 0;
+ public static final int calendarViewShown = 0;
+ public static final int calendarViewStyle = 0;
+ public static final int canRequestEnhancedWebAccessibility = 0;
+ public static final int canRequestFilterKeyEvents = 0;
+ public static final int canRequestTouchExplorationMode = 0;
+ public static final int canRetrieveWindowContent = 0;
+ public static final int candidatesTextStyleSpans = 0;
+ public static final int capitalize = 0;
+ public static final int category = 0;
+ public static final int centerBright = 0;
+ public static final int centerColor = 0;
+ public static final int centerDark = 0;
+ public static final int centerMedium = 0;
+ public static final int centerX = 0;
+ public static final int centerY = 0;
+ public static final int checkBoxPreferenceStyle = 0;
+ public static final int checkMark = 0;
+ public static final int checkMarkTint = 0;
+ public static final int checkMarkTintMode = 0;
+ public static final int checkable = 0;
+ public static final int checkableBehavior = 0;
+ public static final int checkboxStyle = 0;
+ public static final int checked = 0;
+ public static final int checkedButton = 0;
+ public static final int checkedTextViewStyle = 0;
+ public static final int childDivider = 0;
+ public static final int childIndicator = 0;
+ public static final int childIndicatorEnd = 0;
+ public static final int childIndicatorLeft = 0;
+ public static final int childIndicatorRight = 0;
+ public static final int childIndicatorStart = 0;
+ public static final int choiceMode = 0;
+ public static final int clearTaskOnLaunch = 0;
+ public static final int clickable = 0;
+ public static final int clipChildren = 0;
+ public static final int clipOrientation = 0;
+ public static final int clipToPadding = 0;
+ public static final int closeIcon = 0;
+ public static final int codes = 0;
+ public static final int collapseColumns = 0;
+ public static final int collapseContentDescription = 0;
+ public static final int color = 0;
+ public static final int colorAccent = 0;
+ public static final int colorActivatedHighlight = 0;
+ public static final int colorBackground = 0;
+ public static final int colorBackgroundCacheHint = 0;
+ public static final int colorButtonNormal = 0;
+ public static final int colorControlActivated = 0;
+ public static final int colorControlHighlight = 0;
+ public static final int colorControlNormal = 0;
+ public static final int colorEdgeEffect = 0;
+ public static final int colorFocusedHighlight = 0;
+ public static final int colorForeground = 0;
+ public static final int colorForegroundInverse = 0;
+ public static final int colorLongPressedHighlight = 0;
+ public static final int colorMultiSelectHighlight = 0;
+ public static final int colorPressedHighlight = 0;
+ public static final int colorPrimary = 0;
+ public static final int colorPrimaryDark = 0;
+ public static final int columnCount = 0;
+ public static final int columnDelay = 0;
+ public static final int columnOrderPreserved = 0;
+ public static final int columnWidth = 0;
+ public static final int commitIcon = 0;
+ public static final int compatibleWidthLimitDp = 0;
+ public static final int completionHint = 0;
+ public static final int completionHintView = 0;
+ public static final int completionThreshold = 0;
+ public static final int configChanges = 0;
+ public static final int configure = 0;
+ public static final int constantSize = 0;
+ public static final int content = 0;
+ public static final int contentAgeHint = 0;
+ public static final int contentAuthority = 0;
+ public static final int contentDescription = 0;
+ public static final int contentInsetEnd = 0;
+ public static final int contentInsetLeft = 0;
+ public static final int contentInsetRight = 0;
+ public static final int contentInsetStart = 0;
+ public static final int controlX1 = 0;
+ public static final int controlX2 = 0;
+ public static final int controlY1 = 0;
+ public static final int controlY2 = 0;
+ public static final int country = 0;
+ public static final int cropToPadding = 0;
+ public static final int cursorVisible = 0;
+ public static final int customNavigationLayout = 0;
+ public static final int customTokens = 0;
+ public static final int cycles = 0;
+ public static final int dashGap = 0;
+ public static final int dashWidth = 0;
+ public static final int data = 0;
+ public static final int datePickerDialogTheme = 0;
+ public static final int datePickerMode = 0;
+ public static final int datePickerStyle = 0;
+ public static final int dateTextAppearance = 0;
+ public static final int dayOfWeekBackground = 0;
+ public static final int dayOfWeekTextAppearance = 0;
+ public static final int debuggable = 0;
+ public static final int defaultValue = 0;
+ public static final int delay = 0;
+ public static final int dependency = 0;
+ public static final int descendantFocusability = 0;
+ public static final int description = 0;
+ public static final int detachWallpaper = 0;
+ public static final int detailColumn = 0;
+ public static final int detailSocialSummary = 0;
+ public static final int detailsElementBackground = 0;
+ public static final int dial = 0;
+ public static final int dialogIcon = 0;
+ public static final int dialogLayout = 0;
+ public static final int dialogMessage = 0;
+ public static final int dialogPreferenceStyle = 0;
+ public static final int dialogPreferredPadding = 0;
+ public static final int dialogTheme = 0;
+ public static final int dialogTitle = 0;
+ public static final int digits = 0;
+ public static final int direction = 0;
+ public static final int directionDescriptions = 0;
+ public static final int directionPriority = 0;
+ public static final int disableDependentsState = 0;
+ public static final int disabledAlpha = 0;
+ public static final int displayOptions = 0;
+ public static final int dither = 0;
+ public static final int divider = 0;
+ public static final int dividerHeight = 0;
+ public static final int dividerHorizontal = 0;
+ public static final int dividerPadding = 0;
+ public static final int dividerVertical = 0;
+ public static final int documentLaunchMode = 0;
+ public static final int drawSelectorOnTop = 0;
+ public static final int drawable = 0;
+ public static final int drawableBottom = 0;
+ public static final int drawableEnd = 0;
+ public static final int drawableLeft = 0;
+ public static final int drawablePadding = 0;
+ public static final int drawableRight = 0;
+ public static final int drawableStart = 0;
+ public static final int drawableTop = 0;
+ public static final int drawingCacheQuality = 0;
+ public static final int dropDownAnchor = 0;
+ public static final int dropDownHeight = 0;
+ public static final int dropDownHintAppearance = 0;
+ public static final int dropDownHorizontalOffset = 0;
+ public static final int dropDownItemStyle = 0;
+ public static final int dropDownListViewStyle = 0;
+ public static final int dropDownSelector = 0;
+ public static final int dropDownSpinnerStyle = 0;
+ public static final int dropDownVerticalOffset = 0;
+ public static final int dropDownWidth = 0;
+ public static final int duplicateParentState = 0;
+ public static final int duration = 0;
+ public static final int editTextBackground = 0;
+ public static final int editTextColor = 0;
+ public static final int editTextPreferenceStyle = 0;
+ public static final int editTextStyle = 0;
+ public static final int editable = 0;
+ public static final int editorExtras = 0;
+ public static final int elegantTextHeight = 0;
+ public static final int elevation = 0;
+ public static final int ellipsize = 0;
+ public static final int ems = 0;
+ public static final int enabled = 0;
+ public static final int endColor = 0;
+ public static final int endYear = 0;
+ public static final int enterFadeDuration = 0;
+ public static final int entries = 0;
+ public static final int entryValues = 0;
+ public static final int eventsInterceptionEnabled = 0;
+ public static final int excludeClass = 0;
+ public static final int excludeFromRecents = 0;
+ public static final int excludeId = 0;
+ public static final int excludeName = 0;
+ public static final int exitFadeDuration = 0;
+ public static final int expandableListPreferredChildIndicatorLeft = 0;
+ public static final int expandableListPreferredChildIndicatorRight = 0;
+ public static final int expandableListPreferredChildPaddingLeft = 0;
+ public static final int expandableListPreferredItemIndicatorLeft = 0;
+ public static final int expandableListPreferredItemIndicatorRight = 0;
+ public static final int expandableListPreferredItemPaddingLeft = 0;
+ public static final int expandableListViewStyle = 0;
+ public static final int expandableListViewWhiteStyle = 0;
+ public static final int exported = 0;
+ public static final int extraTension = 0;
+ public static final int factor = 0;
+ public static final int fadeDuration = 0;
+ public static final int fadeEnabled = 0;
+ public static final int fadeOffset = 0;
+ public static final int fadeScrollbars = 0;
+ public static final int fadingEdge = 0;
+ public static final int fadingEdgeLength = 0;
+ public static final int fadingMode = 0;
+ public static final int fastScrollAlwaysVisible = 0;
+ public static final int fastScrollEnabled = 0;
+ public static final int fastScrollOverlayPosition = 0;
+ public static final int fastScrollPreviewBackgroundLeft = 0;
+ public static final int fastScrollPreviewBackgroundRight = 0;
+ public static final int fastScrollStyle = 0;
+ public static final int fastScrollTextColor = 0;
+ public static final int fastScrollThumbDrawable = 0;
+ public static final int fastScrollTrackDrawable = 0;
+ public static final int fillAfter = 0;
+ public static final int fillAlpha = 0;
+ public static final int fillBefore = 0;
+ public static final int fillColor = 0;
+ public static final int fillEnabled = 0;
+ public static final int fillViewport = 0;
+ public static final int filter = 0;
+ public static final int filterTouchesWhenObscured = 0;
+ public static final int finishOnCloseSystemDialogs = 0;
+ public static final int finishOnTaskLaunch = 0;
+ public static final int firstDayOfWeek = 0;
+ public static final int fitsSystemWindows = 0;
+ public static final int flipInterval = 0;
+ public static final int focusable = 0;
+ public static final int focusableInTouchMode = 0;
+ public static final int focusedMonthDateColor = 0;
+ public static final int fontFamily = 0;
+ public static final int fontFeatureSettings = 0;
+ public static final int footerDividersEnabled = 0;
+ public static final int foreground = 0;
+ public static final int foregroundGravity = 0;
+ public static final int foregroundTint = 0;
+ public static final int foregroundTintMode = 0;
+ public static final int format = 0;
+ public static final int format12Hour = 0;
+ public static final int format24Hour = 0;
+ public static final int fragment = 0;
+ public static final int fragmentAllowEnterTransitionOverlap = 0;
+ public static final int fragmentAllowReturnTransitionOverlap = 0;
+ public static final int fragmentCloseEnterAnimation = 0;
+ public static final int fragmentCloseExitAnimation = 0;
+ public static final int fragmentEnterTransition = 0;
+ public static final int fragmentExitTransition = 0;
+ public static final int fragmentFadeEnterAnimation = 0;
+ public static final int fragmentFadeExitAnimation = 0;
+ public static final int fragmentOpenEnterAnimation = 0;
+ public static final int fragmentOpenExitAnimation = 0;
+ public static final int fragmentReenterTransition = 0;
+ public static final int fragmentReturnTransition = 0;
+ public static final int fragmentSharedElementEnterTransition = 0;
+ public static final int fragmentSharedElementReturnTransition = 0;
+ public static final int freezesText = 0;
+ public static final int fromAlpha = 0;
+ public static final int fromDegrees = 0;
+ public static final int fromId = 0;
+ public static final int fromScene = 0;
+ public static final int fromXDelta = 0;
+ public static final int fromXScale = 0;
+ public static final int fromYDelta = 0;
+ public static final int fromYScale = 0;
+ public static final int fullBackupOnly = 0;
+ public static final int fullBright = 0;
+ public static final int fullDark = 0;
+ public static final int functionalTest = 0;
+ public static final int galleryItemBackground = 0;
+ public static final int galleryStyle = 0;
+ public static final int gestureColor = 0;
+ public static final int gestureStrokeAngleThreshold = 0;
+ public static final int gestureStrokeLengthThreshold = 0;
+ public static final int gestureStrokeSquarenessThreshold = 0;
+ public static final int gestureStrokeType = 0;
+ public static final int gestureStrokeWidth = 0;
+ public static final int glEsVersion = 0;
+ public static final int goIcon = 0;
+ public static final int gradientRadius = 0;
+ public static final int grantUriPermissions = 0;
+ public static final int gravity = 0;
+ public static final int gridViewStyle = 0;
+ public static final int groupIndicator = 0;
+ public static final int hand_hour = 0;
+ public static final int hand_minute = 0;
+ public static final int handle = 0;
+ public static final int handleProfiling = 0;
+ public static final int hapticFeedbackEnabled = 0;
+ public static final int hardwareAccelerated = 0;
+ public static final int hasCode = 0;
+ public static final int headerAmPmTextAppearance = 0;
+ public static final int headerBackground = 0;
+ public static final int headerDayOfMonthTextAppearance = 0;
+ public static final int headerDividersEnabled = 0;
+ public static final int headerMonthTextAppearance = 0;
+ public static final int headerTimeTextAppearance = 0;
+ public static final int headerYearTextAppearance = 0;
+ public static final int height = 0;
+ public static final int hideOnContentScroll = 0;
+ public static final int hint = 0;
+ public static final int homeAsUpIndicator = 0;
+ public static final int homeLayout = 0;
+ public static final int horizontalDivider = 0;
+ public static final int horizontalGap = 0;
+ public static final int horizontalScrollViewStyle = 0;
+ public static final int horizontalSpacing = 0;
+ public static final int host = 0;
+ public static final int icon = 0;
+ public static final int iconPreview = 0;
+ public static final int iconifiedByDefault = 0;
+ public static final int id = 0;
+ public static final int ignoreGravity = 0;
+ public static final int imageButtonStyle = 0;
+ public static final int imageWellStyle = 0;
+ public static final int imeActionId = 0;
+ public static final int imeActionLabel = 0;
+ public static final int imeExtractEnterAnimation = 0;
+ public static final int imeExtractExitAnimation = 0;
+ public static final int imeFullscreenBackground = 0;
+ public static final int imeOptions = 0;
+ public static final int imeSubtypeExtraValue = 0;
+ public static final int imeSubtypeLocale = 0;
+ public static final int imeSubtypeMode = 0;
+ public static final int immersive = 0;
+ public static final int importantForAccessibility = 0;
+ public static final int inAnimation = 0;
+ public static final int includeFontPadding = 0;
+ public static final int includeInGlobalSearch = 0;
+ public static final int indeterminate = 0;
+ public static final int indeterminateBehavior = 0;
+ public static final int indeterminateDrawable = 0;
+ public static final int indeterminateDuration = 0;
+ public static final int indeterminateOnly = 0;
+ public static final int indeterminateProgressStyle = 0;
+ public static final int indeterminateTint = 0;
+ public static final int indeterminateTintMode = 0;
+ public static final int indicatorEnd = 0;
+ public static final int indicatorLeft = 0;
+ public static final int indicatorRight = 0;
+ public static final int indicatorStart = 0;
+ public static final int inflatedId = 0;
+ public static final int initOrder = 0;
+ public static final int initialKeyguardLayout = 0;
+ public static final int initialLayout = 0;
+ public static final int innerRadius = 0;
+ public static final int innerRadiusRatio = 0;
+ public static final int inputMethod = 0;
+ public static final int inputType = 0;
+ public static final int inset = 0;
+ public static final int insetBottom = 0;
+ public static final int insetLeft = 0;
+ public static final int insetRight = 0;
+ public static final int insetTop = 0;
+ public static final int installLocation = 0;
+ public static final int interpolator = 0;
+ public static final int isAlwaysSyncable = 0;
+ public static final int isAsciiCapable = 0;
+ public static final int isAuxiliary = 0;
+ public static final int isDefault = 0;
+ public static final int isGame = 0;
+ public static final int isIndicator = 0;
+ public static final int isModifier = 0;
+ public static final int isRepeatable = 0;
+ public static final int isScrollContainer = 0;
+ public static final int isSticky = 0;
+ public static final int isolatedProcess = 0;
+ public static final int itemBackground = 0;
+ public static final int itemIconDisabledAlpha = 0;
+ public static final int itemPadding = 0;
+ public static final int itemTextAppearance = 0;
+ public static final int keepScreenOn = 0;
+ public static final int key = 0;
+ public static final int keyBackground = 0;
+ public static final int keyEdgeFlags = 0;
+ public static final int keyHeight = 0;
+ public static final int keyIcon = 0;
+ public static final int keyLabel = 0;
+ public static final int keyOutputText = 0;
+ public static final int keyPreviewHeight = 0;
+ public static final int keyPreviewLayout = 0;
+ public static final int keyPreviewOffset = 0;
+ public static final int keySet = 0;
+ public static final int keyTextColor = 0;
+ public static final int keyTextSize = 0;
+ public static final int keyWidth = 0;
+ public static final int keyboardLayout = 0;
+ public static final int keyboardMode = 0;
+ public static final int keycode = 0;
+ public static final int killAfterRestore = 0;
+ public static final int label = 0;
+ public static final int labelFor = 0;
+ public static final int labelTextSize = 0;
+ public static final int largeHeap = 0;
+ public static final int largeScreens = 0;
+ public static final int largestWidthLimitDp = 0;
+ public static final int launchMode = 0;
+ public static final int launchTaskBehindSourceAnimation = 0;
+ public static final int launchTaskBehindTargetAnimation = 0;
+ public static final int layerType = 0;
+ public static final int layout = 0;
+ public static final int layoutAnimation = 0;
+ public static final int layoutDirection = 0;
+ public static final int layoutMode = 0;
+ public static final int layout_above = 0;
+ public static final int layout_alignBaseline = 0;
+ public static final int layout_alignBottom = 0;
+ public static final int layout_alignEnd = 0;
+ public static final int layout_alignLeft = 0;
+ public static final int layout_alignParentBottom = 0;
+ public static final int layout_alignParentEnd = 0;
+ public static final int layout_alignParentLeft = 0;
+ public static final int layout_alignParentRight = 0;
+ public static final int layout_alignParentStart = 0;
+ public static final int layout_alignParentTop = 0;
+ public static final int layout_alignRight = 0;
+ public static final int layout_alignStart = 0;
+ public static final int layout_alignTop = 0;
+ public static final int layout_alignWithParentIfMissing = 0;
+ public static final int layout_below = 0;
+ public static final int layout_centerHorizontal = 0;
+ public static final int layout_centerInParent = 0;
+ public static final int layout_centerVertical = 0;
+ public static final int layout_column = 0;
+ public static final int layout_columnSpan = 0;
+ public static final int layout_columnWeight = 0;
+ public static final int layout_gravity = 0;
+ public static final int layout_height = 0;
+ public static final int layout_margin = 0;
+ public static final int layout_marginBottom = 0;
+ public static final int layout_marginEnd = 0;
+ public static final int layout_marginLeft = 0;
+ public static final int layout_marginRight = 0;
+ public static final int layout_marginStart = 0;
+ public static final int layout_marginTop = 0;
+ public static final int layout_row = 0;
+ public static final int layout_rowSpan = 0;
+ public static final int layout_rowWeight = 0;
+ public static final int layout_scale = 0;
+ public static final int layout_span = 0;
+ public static final int layout_toEndOf = 0;
+ public static final int layout_toLeftOf = 0;
+ public static final int layout_toRightOf = 0;
+ public static final int layout_toStartOf = 0;
+ public static final int layout_weight = 0;
+ public static final int layout_width = 0;
+ public static final int layout_x = 0;
+ public static final int layout_y = 0;
+ public static final int left = 0;
+ public static final int letterSpacing = 0;
+ public static final int lineSpacingExtra = 0;
+ public static final int lineSpacingMultiplier = 0;
+ public static final int lines = 0;
+ public static final int linksClickable = 0;
+ public static final int listChoiceBackgroundIndicator = 0;
+ public static final int listChoiceIndicatorMultiple = 0;
+ public static final int listChoiceIndicatorSingle = 0;
+ public static final int listDivider = 0;
+ public static final int listDividerAlertDialog = 0;
+ public static final int listPopupWindowStyle = 0;
+ public static final int listPreferredItemHeight = 0;
+ public static final int listPreferredItemHeightLarge = 0;
+ public static final int listPreferredItemHeightSmall = 0;
+ public static final int listPreferredItemPaddingEnd = 0;
+ public static final int listPreferredItemPaddingLeft = 0;
+ public static final int listPreferredItemPaddingRight = 0;
+ public static final int listPreferredItemPaddingStart = 0;
+ public static final int listSelector = 0;
+ public static final int listSeparatorTextViewStyle = 0;
+ public static final int listViewStyle = 0;
+ public static final int listViewWhiteStyle = 0;
+ public static final int logo = 0;
+ public static final int longClickable = 0;
+ public static final int loopViews = 0;
+ public static final int manageSpaceActivity = 0;
+ public static final int mapViewStyle = 0;
+ public static final int marqueeRepeatLimit = 0;
+ public static final int matchOrder = 0;
+ public static final int max = 0;
+ public static final int maxDate = 0;
+ public static final int maxEms = 0;
+ public static final int maxHeight = 0;
+ public static final int maxItemsPerRow = 0;
+ public static final int maxLength = 0;
+ public static final int maxLevel = 0;
+ public static final int maxLines = 0;
+ public static final int maxRecents = 0;
+ public static final int maxRows = 0;
+ public static final int maxSdkVersion = 0;
+ public static final int maxWidth = 0;
+ public static final int maximumAngle = 0;
+ public static final int measureAllChildren = 0;
+ public static final int measureWithLargestChild = 0;
+ public static final int mediaRouteButtonStyle = 0;
+ public static final int mediaRouteTypes = 0;
+ public static final int menuCategory = 0;
+ public static final int mimeType = 0;
+ public static final int minDate = 0;
+ public static final int minEms = 0;
+ public static final int minHeight = 0;
+ public static final int minLevel = 0;
+ public static final int minLines = 0;
+ public static final int minResizeHeight = 0;
+ public static final int minResizeWidth = 0;
+ public static final int minSdkVersion = 0;
+ public static final int minWidth = 0;
+ public static final int minimumHorizontalAngle = 0;
+ public static final int minimumVerticalAngle = 0;
+ public static final int mipMap = 0;
+ public static final int mirrorForRtl = 0;
+ public static final int mode = 0;
+ public static final int moreIcon = 0;
+ public static final int multiArch = 0;
+ public static final int multiprocess = 0;
+ public static final int name = 0;
+ public static final int navigationBarColor = 0;
+ public static final int navigationContentDescription = 0;
+ public static final int navigationIcon = 0;
+ public static final int navigationMode = 0;
+ public static final int negativeButtonText = 0;
+ public static final int nestedScrollingEnabled = 0;
+ public static final int nextFocusDown = 0;
+ public static final int nextFocusForward = 0;
+ public static final int nextFocusLeft = 0;
+ public static final int nextFocusRight = 0;
+ public static final int nextFocusUp = 0;
+ public static final int noHistory = 0;
+ public static final int normalScreens = 0;
+ public static final int notificationTimeout = 0;
+ public static final int numColumns = 0;
+ public static final int numStars = 0;
+ public static final int numbersBackgroundColor = 0;
+ public static final int numbersSelectorColor = 0;
+ public static final int numbersTextColor = 0;
+ public static final int numeric = 0;
+ public static final int numericShortcut = 0;
+ public static final int onClick = 0;
+ public static final int oneshot = 0;
+ public static final int opacity = 0;
+ public static final int order = 0;
+ public static final int orderInCategory = 0;
+ public static final int ordering = 0;
+ public static final int orderingFromXml = 0;
+ public static final int orientation = 0;
+ public static final int outAnimation = 0;
+ public static final int outlineProvider = 0;
+ public static final int overScrollFooter = 0;
+ public static final int overScrollHeader = 0;
+ public static final int overScrollMode = 0;
+ public static final int overlapAnchor = 0;
+ public static final int overridesImplicitlyEnabledSubtype = 0;
+ public static final int packageNames = 0;
+ public static final int padding = 0;
+ public static final int paddingBottom = 0;
+ public static final int paddingEnd = 0;
+ public static final int paddingLeft = 0;
+ public static final int paddingMode = 0;
+ public static final int paddingRight = 0;
+ public static final int paddingStart = 0;
+ public static final int paddingTop = 0;
+ public static final int panelBackground = 0;
+ public static final int panelColorBackground = 0;
+ public static final int panelColorForeground = 0;
+ public static final int panelFullBackground = 0;
+ public static final int panelTextAppearance = 0;
+ public static final int parentActivityName = 0;
+ public static final int password = 0;
+ public static final int path = 0;
+ public static final int pathData = 0;
+ public static final int pathPattern = 0;
+ public static final int pathPrefix = 0;
+ public static final int patternPathData = 0;
+ public static final int permission = 0;
+ public static final int permissionFlags = 0;
+ public static final int permissionGroup = 0;
+ public static final int permissionGroupFlags = 0;
+ public static final int persistableMode = 0;
+ public static final int persistent = 0;
+ public static final int persistentDrawingCache = 0;
+ public static final int phoneNumber = 0;
+ public static final int pivotX = 0;
+ public static final int pivotY = 0;
+ public static final int popupAnimationStyle = 0;
+ public static final int popupBackground = 0;
+ public static final int popupCharacters = 0;
+ public static final int popupElevation = 0;
+ public static final int popupKeyboard = 0;
+ public static final int popupLayout = 0;
+ public static final int popupMenuStyle = 0;
+ public static final int popupTheme = 0;
+ public static final int popupWindowStyle = 0;
+ public static final int port = 0;
+ public static final int positiveButtonText = 0;
+ public static final int preferenceCategoryStyle = 0;
+ public static final int preferenceInformationStyle = 0;
+ public static final int preferenceLayoutChild = 0;
+ public static final int preferenceScreenStyle = 0;
+ public static final int preferenceStyle = 0;
+ public static final int presentationTheme = 0;
+ public static final int previewImage = 0;
+ public static final int priority = 0;
+ public static final int privateImeOptions = 0;
+ public static final int private_resource_pad1 = 0;
+ public static final int private_resource_pad10 = 0;
+ public static final int private_resource_pad11 = 0;
+ public static final int private_resource_pad12 = 0;
+ public static final int private_resource_pad13 = 0;
+ public static final int private_resource_pad14 = 0;
+ public static final int private_resource_pad15 = 0;
+ public static final int private_resource_pad16 = 0;
+ public static final int private_resource_pad17 = 0;
+ public static final int private_resource_pad18 = 0;
+ public static final int private_resource_pad19 = 0;
+ public static final int private_resource_pad2 = 0;
+ public static final int private_resource_pad20 = 0;
+ public static final int private_resource_pad21 = 0;
+ public static final int private_resource_pad22 = 0;
+ public static final int private_resource_pad23 = 0;
+ public static final int private_resource_pad24 = 0;
+ public static final int private_resource_pad25 = 0;
+ public static final int private_resource_pad26 = 0;
+ public static final int private_resource_pad27 = 0;
+ public static final int private_resource_pad28 = 0;
+ public static final int private_resource_pad29 = 0;
+ public static final int private_resource_pad3 = 0;
+ public static final int private_resource_pad30 = 0;
+ public static final int private_resource_pad31 = 0;
+ public static final int private_resource_pad32 = 0;
+ public static final int private_resource_pad33 = 0;
+ public static final int private_resource_pad34 = 0;
+ public static final int private_resource_pad35 = 0;
+ public static final int private_resource_pad36 = 0;
+ public static final int private_resource_pad37 = 0;
+ public static final int private_resource_pad38 = 0;
+ public static final int private_resource_pad39 = 0;
+ public static final int private_resource_pad4 = 0;
+ public static final int private_resource_pad40 = 0;
+ public static final int private_resource_pad41 = 0;
+ public static final int private_resource_pad42 = 0;
+ public static final int private_resource_pad43 = 0;
+ public static final int private_resource_pad44 = 0;
+ public static final int private_resource_pad45 = 0;
+ public static final int private_resource_pad46 = 0;
+ public static final int private_resource_pad47 = 0;
+ public static final int private_resource_pad48 = 0;
+ public static final int private_resource_pad49 = 0;
+ public static final int private_resource_pad5 = 0;
+ public static final int private_resource_pad50 = 0;
+ public static final int private_resource_pad6 = 0;
+ public static final int private_resource_pad7 = 0;
+ public static final int private_resource_pad8 = 0;
+ public static final int private_resource_pad9 = 0;
+ public static final int process = 0;
+ public static final int progress = 0;
+ public static final int progressBackgroundTint = 0;
+ public static final int progressBackgroundTintMode = 0;
+ public static final int progressBarPadding = 0;
+ public static final int progressBarStyle = 0;
+ public static final int progressBarStyleHorizontal = 0;
+ public static final int progressBarStyleInverse = 0;
+ public static final int progressBarStyleLarge = 0;
+ public static final int progressBarStyleLargeInverse = 0;
+ public static final int progressBarStyleSmall = 0;
+ public static final int progressBarStyleSmallInverse = 0;
+ public static final int progressBarStyleSmallTitle = 0;
+ public static final int progressDrawable = 0;
+ public static final int progressTint = 0;
+ public static final int progressTintMode = 0;
+ public static final int prompt = 0;
+ public static final int propertyName = 0;
+ public static final int propertyXName = 0;
+ public static final int propertyYName = 0;
+ public static final int protectionLevel = 0;
+ public static final int publicKey = 0;
+ public static final int queryActionMsg = 0;
+ public static final int queryAfterZeroResults = 0;
+ public static final int queryBackground = 0;
+ public static final int queryHint = 0;
+ public static final int quickContactBadgeStyleSmallWindowLarge = 0;
+ public static final int quickContactBadgeStyleSmallWindowMedium = 0;
+ public static final int quickContactBadgeStyleSmallWindowSmall = 0;
+ public static final int quickContactBadgeStyleWindowLarge = 0;
+ public static final int quickContactBadgeStyleWindowMedium = 0;
+ public static final int quickContactBadgeStyleWindowSmall = 0;
+ public static final int radioButtonStyle = 0;
+ public static final int radius = 0;
+ public static final int rating = 0;
+ public static final int ratingBarStyle = 0;
+ public static final int ratingBarStyleIndicator = 0;
+ public static final int ratingBarStyleSmall = 0;
+ public static final int readPermission = 0;
+ public static final int recognitionService = 0;
+ public static final int relinquishTaskIdentity = 0;
+ public static final int reparent = 0;
+ public static final int reparentWithOverlay = 0;
+ public static final int repeatCount = 0;
+ public static final int repeatMode = 0;
+ public static final int reqFiveWayNav = 0;
+ public static final int reqHardKeyboard = 0;
+ public static final int reqKeyboardType = 0;
+ public static final int reqNavigation = 0;
+ public static final int reqTouchScreen = 0;
+ public static final int requireDeviceUnlock = 0;
+ public static final int required = 0;
+ public static final int requiredAccountType = 0;
+ public static final int requiredForAllUsers = 0;
+ public static final int requiresFadingEdge = 0;
+ public static final int requiresSmallestWidthDp = 0;
+ public static final int resizeClip = 0;
+ public static final int resizeMode = 0;
+ public static final int resizeable = 0;
+ public static final int resource = 0;
+ public static final int restoreAnyVersion = 0;
+ public static final int restoreNeedsApplication = 0;
+ public static final int restrictedAccountType = 0;
+ public static final int restrictionType = 0;
+ public static final int resumeWhilePausing = 0;
+ public static final int reversible = 0;
+ public static final int right = 0;
+ public static final int ringtonePreferenceStyle = 0;
+ public static final int ringtoneType = 0;
+ public static final int rotation = 0;
+ public static final int rotationX = 0;
+ public static final int rotationY = 0;
+ public static final int rowCount = 0;
+ public static final int rowDelay = 0;
+ public static final int rowEdgeFlags = 0;
+ public static final int rowHeight = 0;
+ public static final int rowOrderPreserved = 0;
+ public static final int saveEnabled = 0;
+ public static final int scaleGravity = 0;
+ public static final int scaleHeight = 0;
+ public static final int scaleType = 0;
+ public static final int scaleWidth = 0;
+ public static final int scaleX = 0;
+ public static final int scaleY = 0;
+ public static final int scheme = 0;
+ public static final int screenDensity = 0;
+ public static final int screenOrientation = 0;
+ public static final int screenSize = 0;
+ public static final int scrollHorizontally = 0;
+ public static final int scrollViewStyle = 0;
+ public static final int scrollX = 0;
+ public static final int scrollY = 0;
+ public static final int scrollbarAlwaysDrawHorizontalTrack = 0;
+ public static final int scrollbarAlwaysDrawVerticalTrack = 0;
+ public static final int scrollbarDefaultDelayBeforeFade = 0;
+ public static final int scrollbarFadeDuration = 0;
+ public static final int scrollbarSize = 0;
+ public static final int scrollbarStyle = 0;
+ public static final int scrollbarThumbHorizontal = 0;
+ public static final int scrollbarThumbVertical = 0;
+ public static final int scrollbarTrackHorizontal = 0;
+ public static final int scrollbarTrackVertical = 0;
+ public static final int scrollbars = 0;
+ public static final int scrollingCache = 0;
+ public static final int searchButtonText = 0;
+ public static final int searchIcon = 0;
+ public static final int searchKeyphrase = 0;
+ public static final int searchKeyphraseId = 0;
+ public static final int searchKeyphraseRecognitionFlags = 0;
+ public static final int searchKeyphraseSupportedLocales = 0;
+ public static final int searchMode = 0;
+ public static final int searchSettingsDescription = 0;
+ public static final int searchSuggestAuthority = 0;
+ public static final int searchSuggestIntentAction = 0;
+ public static final int searchSuggestIntentData = 0;
+ public static final int searchSuggestPath = 0;
+ public static final int searchSuggestSelection = 0;
+ public static final int searchSuggestThreshold = 0;
+ public static final int searchViewStyle = 0;
+ public static final int secondaryProgress = 0;
+ public static final int secondaryProgressTint = 0;
+ public static final int secondaryProgressTintMode = 0;
+ public static final int seekBarStyle = 0;
+ public static final int segmentedButtonStyle = 0;
+ public static final int selectAllOnFocus = 0;
+ public static final int selectable = 0;
+ public static final int selectableItemBackground = 0;
+ public static final int selectableItemBackgroundBorderless = 0;
+ public static final int selectedDateVerticalBar = 0;
+ public static final int selectedWeekBackgroundColor = 0;
+ public static final int sessionService = 0;
+ public static final int settingsActivity = 0;
+ public static final int setupActivity = 0;
+ public static final int shadowColor = 0;
+ public static final int shadowDx = 0;
+ public static final int shadowDy = 0;
+ public static final int shadowRadius = 0;
+ public static final int shape = 0;
+ public static final int shareInterpolator = 0;
+ public static final int sharedUserId = 0;
+ public static final int sharedUserLabel = 0;
+ public static final int shouldDisableView = 0;
+ public static final int showAsAction = 0;
+ public static final int showDefault = 0;
+ public static final int showDividers = 0;
+ public static final int showOnLockScreen = 0;
+ public static final int showSilent = 0;
+ public static final int showText = 0;
+ public static final int showWeekNumber = 0;
+ public static final int shownWeekCount = 0;
+ public static final int shrinkColumns = 0;
+ public static final int singleLine = 0;
+ public static final int singleUser = 0;
+ public static final int slideEdge = 0;
+ public static final int smallIcon = 0;
+ public static final int smallScreens = 0;
+ public static final int smoothScrollbar = 0;
+ public static final int solidColor = 0;
+ public static final int soundEffectsEnabled = 0;
+ public static final int spacing = 0;
+ public static final int spinnerDropDownItemStyle = 0;
+ public static final int spinnerItemStyle = 0;
+ public static final int spinnerMode = 0;
+ public static final int spinnerStyle = 0;
+ public static final int spinnersShown = 0;
+ public static final int splitMotionEvents = 0;
+ public static final int splitTrack = 0;
+ public static final int spotShadowAlpha = 0;
+ public static final int src = 0;
+ public static final int ssp = 0;
+ public static final int sspPattern = 0;
+ public static final int sspPrefix = 0;
+ public static final int stackFromBottom = 0;
+ public static final int stackViewStyle = 0;
+ public static final int starStyle = 0;
+ public static final int startColor = 0;
+ public static final int startDelay = 0;
+ public static final int startOffset = 0;
+ public static final int startYear = 0;
+ public static final int stateListAnimator = 0;
+ public static final int stateNotNeeded = 0;
+ public static final int state_above_anchor = 0;
+ public static final int state_accelerated = 0;
+ public static final int state_activated = 0;
+ public static final int state_active = 0;
+ public static final int state_checkable = 0;
+ public static final int state_checked = 0;
+ public static final int state_drag_can_accept = 0;
+ public static final int state_drag_hovered = 0;
+ public static final int state_empty = 0;
+ public static final int state_enabled = 0;
+ public static final int state_expanded = 0;
+ public static final int state_first = 0;
+ public static final int state_focused = 0;
+ public static final int state_hovered = 0;
+ public static final int state_last = 0;
+ public static final int state_long_pressable = 0;
+ public static final int state_middle = 0;
+ public static final int state_multiline = 0;
+ public static final int state_pressed = 0;
+ public static final int state_selected = 0;
+ public static final int state_single = 0;
+ public static final int state_window_focused = 0;
+ public static final int staticWallpaperPreview = 0;
+ public static final int statusBarColor = 0;
+ public static final int stepSize = 0;
+ public static final int stopWithTask = 0;
+ public static final int streamType = 0;
+ public static final int stretchColumns = 0;
+ public static final int stretchMode = 0;
+ public static final int strokeAlpha = 0;
+ public static final int strokeColor = 0;
+ public static final int strokeLineCap = 0;
+ public static final int strokeLineJoin = 0;
+ public static final int strokeMiterLimit = 0;
+ public static final int strokeWidth = 0;
+ public static final int submitBackground = 0;
+ public static final int subtitle = 0;
+ public static final int subtitleTextAppearance = 0;
+ public static final int subtitleTextStyle = 0;
+ public static final int subtypeExtraValue = 0;
+ public static final int subtypeId = 0;
+ public static final int subtypeLocale = 0;
+ public static final int suggestActionMsg = 0;
+ public static final int suggestActionMsgColumn = 0;
+ public static final int suggestionRowLayout = 0;
+ public static final int summary = 0;
+ public static final int summaryColumn = 0;
+ public static final int summaryOff = 0;
+ public static final int summaryOn = 0;
+ public static final int supportsRtl = 0;
+ public static final int supportsSwitchingToNextInputMethod = 0;
+ public static final int supportsUploading = 0;
+ public static final int switchMinWidth = 0;
+ public static final int switchPadding = 0;
+ public static final int switchPreferenceStyle = 0;
+ public static final int switchStyle = 0;
+ public static final int switchTextAppearance = 0;
+ public static final int switchTextOff = 0;
+ public static final int switchTextOn = 0;
+ public static final int syncable = 0;
+ public static final int tabStripEnabled = 0;
+ public static final int tabStripLeft = 0;
+ public static final int tabStripRight = 0;
+ public static final int tabWidgetStyle = 0;
+ public static final int tag = 0;
+ public static final int targetActivity = 0;
+ public static final int targetClass = 0;
+ public static final int targetDescriptions = 0;
+ public static final int targetId = 0;
+ public static final int targetName = 0;
+ public static final int targetPackage = 0;
+ public static final int targetSdkVersion = 0;
+ public static final int taskAffinity = 0;
+ public static final int taskCloseEnterAnimation = 0;
+ public static final int taskCloseExitAnimation = 0;
+ public static final int taskOpenEnterAnimation = 0;
+ public static final int taskOpenExitAnimation = 0;
+ public static final int taskToBackEnterAnimation = 0;
+ public static final int taskToBackExitAnimation = 0;
+ public static final int taskToFrontEnterAnimation = 0;
+ public static final int taskToFrontExitAnimation = 0;
+ public static final int tension = 0;
+ public static final int testOnly = 0;
+ public static final int text = 0;
+ public static final int textAlignment = 0;
+ public static final int textAllCaps = 0;
+ public static final int textAppearance = 0;
+ public static final int textAppearanceButton = 0;
+ public static final int textAppearanceInverse = 0;
+ public static final int textAppearanceLarge = 0;
+ public static final int textAppearanceLargeInverse = 0;
+ public static final int textAppearanceLargePopupMenu = 0;
+ public static final int textAppearanceListItem = 0;
+ public static final int textAppearanceListItemSecondary = 0;
+ public static final int textAppearanceListItemSmall = 0;
+ public static final int textAppearanceMedium = 0;
+ public static final int textAppearanceMediumInverse = 0;
+ public static final int textAppearanceSearchResultSubtitle = 0;
+ public static final int textAppearanceSearchResultTitle = 0;
+ public static final int textAppearanceSmall = 0;
+ public static final int textAppearanceSmallInverse = 0;
+ public static final int textAppearanceSmallPopupMenu = 0;
+ public static final int textCheckMark = 0;
+ public static final int textCheckMarkInverse = 0;
+ public static final int textColor = 0;
+ public static final int textColorAlertDialogListItem = 0;
+ public static final int textColorHighlight = 0;
+ public static final int textColorHighlightInverse = 0;
+ public static final int textColorHint = 0;
+ public static final int textColorHintInverse = 0;
+ public static final int textColorLink = 0;
+ public static final int textColorLinkInverse = 0;
+ public static final int textColorPrimary = 0;
+ public static final int textColorPrimaryDisableOnly = 0;
+ public static final int textColorPrimaryInverse = 0;
+ public static final int textColorPrimaryInverseDisableOnly = 0;
+ public static final int textColorPrimaryInverseNoDisable = 0;
+ public static final int textColorPrimaryNoDisable = 0;
+ public static final int textColorSecondary = 0;
+ public static final int textColorSecondaryInverse = 0;
+ public static final int textColorSecondaryInverseNoDisable = 0;
+ public static final int textColorSecondaryNoDisable = 0;
+ public static final int textColorTertiary = 0;
+ public static final int textColorTertiaryInverse = 0;
+ public static final int textCursorDrawable = 0;
+ public static final int textDirection = 0;
+ public static final int textEditNoPasteWindowLayout = 0;
+ public static final int textEditPasteWindowLayout = 0;
+ public static final int textEditSideNoPasteWindowLayout = 0;
+ public static final int textEditSidePasteWindowLayout = 0;
+ public static final int textEditSuggestionItemLayout = 0;
+ public static final int textFilterEnabled = 0;
+ public static final int textIsSelectable = 0;
+ public static final int textOff = 0;
+ public static final int textOn = 0;
+ public static final int textScaleX = 0;
+ public static final int textSelectHandle = 0;
+ public static final int textSelectHandleLeft = 0;
+ public static final int textSelectHandleRight = 0;
+ public static final int textSelectHandleWindowStyle = 0;
+ public static final int textSize = 0;
+ public static final int textStyle = 0;
+ public static final int textSuggestionsWindowStyle = 0;
+ public static final int textViewStyle = 0;
+ public static final int theme = 0;
+ public static final int thickness = 0;
+ public static final int thicknessRatio = 0;
+ public static final int thumb = 0;
+ public static final int thumbOffset = 0;
+ public static final int thumbTextPadding = 0;
+ public static final int thumbTint = 0;
+ public static final int thumbTintMode = 0;
+ public static final int thumbnail = 0;
+ public static final int tileMode = 0;
+ public static final int tileModeX = 0;
+ public static final int tileModeY = 0;
+ public static final int timePickerDialogTheme = 0;
+ public static final int timePickerMode = 0;
+ public static final int timePickerStyle = 0;
+ public static final int timeZone = 0;
+ public static final int tint = 0;
+ public static final int tintMode = 0;
+ public static final int title = 0;
+ public static final int titleCondensed = 0;
+ public static final int titleTextAppearance = 0;
+ public static final int titleTextStyle = 0;
+ public static final int toAlpha = 0;
+ public static final int toDegrees = 0;
+ public static final int toId = 0;
+ public static final int toScene = 0;
+ public static final int toXDelta = 0;
+ public static final int toXScale = 0;
+ public static final int toYDelta = 0;
+ public static final int toYScale = 0;
+ public static final int toolbarStyle = 0;
+ public static final int top = 0;
+ public static final int topBright = 0;
+ public static final int topDark = 0;
+ public static final int topLeftRadius = 0;
+ public static final int topOffset = 0;
+ public static final int topRightRadius = 0;
+ public static final int touchscreenBlocksFocus = 0;
+ public static final int track = 0;
+ public static final int transcriptMode = 0;
+ public static final int transformPivotX = 0;
+ public static final int transformPivotY = 0;
+ public static final int transition = 0;
+ public static final int transitionGroup = 0;
+ public static final int transitionName = 0;
+ public static final int transitionOrdering = 0;
+ public static final int transitionVisibilityMode = 0;
+ public static final int translateX = 0;
+ public static final int translateY = 0;
+ public static final int translationX = 0;
+ public static final int translationY = 0;
+ public static final int translationZ = 0;
+ public static final int trimPathEnd = 0;
+ public static final int trimPathOffset = 0;
+ public static final int trimPathStart = 0;
+ public static final int type = 0;
+ public static final int typeface = 0;
+ public static final int uiOptions = 0;
+ public static final int uncertainGestureColor = 0;
+ public static final int unfocusedMonthDateColor = 0;
+ public static final int unselectedAlpha = 0;
+ public static final int updatePeriodMillis = 0;
+ public static final int useDefaultMargins = 0;
+ public static final int useIntrinsicSizeAsMinimum = 0;
+ public static final int useLevel = 0;
+ public static final int userVisible = 0;
+ public static final int value = 0;
+ public static final int valueFrom = 0;
+ public static final int valueTo = 0;
+ public static final int valueType = 0;
+ public static final int variablePadding = 0;
+ public static final int vendor = 0;
+ public static final int versionCode = 0;
+ public static final int versionName = 0;
+ public static final int verticalCorrection = 0;
+ public static final int verticalDivider = 0;
+ public static final int verticalGap = 0;
+ public static final int verticalScrollbarPosition = 0;
+ public static final int verticalSpacing = 0;
+ public static final int viewportHeight = 0;
+ public static final int viewportWidth = 0;
+ public static final int visibility = 0;
+ public static final int visible = 0;
+ public static final int vmSafeMode = 0;
+ public static final int voiceIcon = 0;
+ public static final int voiceLanguage = 0;
+ public static final int voiceLanguageModel = 0;
+ public static final int voiceMaxResults = 0;
+ public static final int voicePromptText = 0;
+ public static final int voiceSearchMode = 0;
+ public static final int wallpaperCloseEnterAnimation = 0;
+ public static final int wallpaperCloseExitAnimation = 0;
+ public static final int wallpaperIntraCloseEnterAnimation = 0;
+ public static final int wallpaperIntraCloseExitAnimation = 0;
+ public static final int wallpaperIntraOpenEnterAnimation = 0;
+ public static final int wallpaperIntraOpenExitAnimation = 0;
+ public static final int wallpaperOpenEnterAnimation = 0;
+ public static final int wallpaperOpenExitAnimation = 0;
+ public static final int webTextViewStyle = 0;
+ public static final int webViewStyle = 0;
+ public static final int weekDayTextAppearance = 0;
+ public static final int weekNumberColor = 0;
+ public static final int weekSeparatorLineColor = 0;
+ public static final int weightSum = 0;
+ public static final int widgetCategory = 0;
+ public static final int widgetLayout = 0;
+ public static final int width = 0;
+ public static final int windowActionBar = 0;
+ public static final int windowActionBarOverlay = 0;
+ public static final int windowActionModeOverlay = 0;
+ public static final int windowActivityTransitions = 0;
+ public static final int windowAllowEnterTransitionOverlap = 0;
+ public static final int windowAllowReturnTransitionOverlap = 0;
+ public static final int windowAnimationStyle = 0;
+ public static final int windowBackground = 0;
+ public static final int windowClipToOutline = 0;
+ public static final int windowCloseOnTouchOutside = 0;
+ public static final int windowContentOverlay = 0;
+ public static final int windowContentTransitionManager = 0;
+ public static final int windowContentTransitions = 0;
+ public static final int windowDisablePreview = 0;
+ public static final int windowDrawsSystemBarBackgrounds = 0;
+ public static final int windowElevation = 0;
+ public static final int windowEnableSplitTouch = 0;
+ public static final int windowEnterAnimation = 0;
+ public static final int windowEnterTransition = 0;
+ public static final int windowExitAnimation = 0;
+ public static final int windowExitTransition = 0;
+ public static final int windowFrame = 0;
+ public static final int windowFullscreen = 0;
+ public static final int windowHideAnimation = 0;
+ public static final int windowIsFloating = 0;
+ public static final int windowIsTranslucent = 0;
+ public static final int windowMinWidthMajor = 0;
+ public static final int windowMinWidthMinor = 0;
+ public static final int windowNoDisplay = 0;
+ public static final int windowNoTitle = 0;
+ public static final int windowOverscan = 0;
+ public static final int windowReenterTransition = 0;
+ public static final int windowReturnTransition = 0;
+ public static final int windowSharedElementEnterTransition = 0;
+ public static final int windowSharedElementExitTransition = 0;
+ public static final int windowSharedElementReenterTransition = 0;
+ public static final int windowSharedElementReturnTransition = 0;
+ public static final int windowSharedElementsUseOverlay = 0;
+ public static final int windowShowAnimation = 0;
+ public static final int windowShowWallpaper = 0;
+ public static final int windowSoftInputMode = 0;
+ public static final int windowSwipeToDismiss = 0;
+ public static final int windowTitleBackgroundStyle = 0;
+ public static final int windowTitleSize = 0;
+ public static final int windowTitleStyle = 0;
+ public static final int windowTransitionBackgroundFadeDuration = 0;
+ public static final int windowTranslucentNavigation = 0;
+ public static final int windowTranslucentStatus = 0;
+ public static final int writePermission = 0;
+ public static final int x = 0;
+ public static final int xlargeScreens = 0;
+ public static final int y = 0;
+ public static final int yearListItemTextAppearance = 0;
+ public static final int yearListSelectorColor = 0;
+ public static final int yesNoPreferenceStyle = 0;
+ public static final int zAdjustment = 0;
+}
diff --git a/benchmarks/regression/RandomBenchmark.java b/benchmarks/regression/RandomBenchmark.java
new file mode 100644
index 0000000..284c63f
--- /dev/null
+++ b/benchmarks/regression/RandomBenchmark.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.security.SecureRandom;
+import java.util.Random;
+
+public class RandomBenchmark {
+ public void timeNewRandom(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Random rng = new Random();
+ rng.nextInt();
+ }
+ }
+
+ public void timeReusedRandom(int reps) throws Exception {
+ Random rng = new Random();
+ for (int i = 0; i < reps; ++i) {
+ rng.nextInt();
+ }
+ }
+
+ public void timeReusedSecureRandom(int reps) throws Exception {
+ SecureRandom rng = new SecureRandom();
+ for (int i = 0; i < reps; ++i) {
+ rng.nextInt();
+ }
+ }
+
+ public void timeNewSecureRandom(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ SecureRandom rng = new SecureRandom();
+ rng.nextInt();
+ }
+ }
+}
diff --git a/benchmarks/regression/RealToStringBenchmark.java b/benchmarks/regression/RealToStringBenchmark.java
new file mode 100644
index 0000000..dcdae39
--- /dev/null
+++ b/benchmarks/regression/RealToStringBenchmark.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class RealToStringBenchmark {
+
+ private static final float SMALL = -123.45f;
+ private static final float MEDIUM = -123.45e8f;
+ private static final float LARGE = -123.45e36f;
+
+ public void timeFloat_toString_NaN(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(Float.NaN);
+ }
+ }
+
+ public void timeFloat_toString_NEGATIVE_INFINITY(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(Float.NEGATIVE_INFINITY);
+ }
+ }
+
+ public void timeFloat_toString_POSITIVE_INFINITY(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(Float.POSITIVE_INFINITY);
+ }
+ }
+
+ public void timeFloat_toString_zero(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(0.0f);
+ }
+ }
+
+ public void timeFloat_toString_minusZero(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(-0.0f);
+ }
+ }
+
+ public void timeFloat_toString_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(SMALL);
+ }
+ }
+
+ public void timeFloat_toString_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(MEDIUM);
+ }
+ }
+
+ public void timeFloat_toString_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.toString(LARGE);
+ }
+ }
+
+ public void timeStringBuilder_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(SMALL);
+ }
+ }
+
+ public void timeStringBuilder_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(MEDIUM);
+ }
+ }
+
+ public void timeStringBuilder_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ new StringBuilder().append(LARGE);
+ }
+ }
+
+ public void timeFormatter_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%f", SMALL);
+ }
+ }
+
+ public void timeFormatter_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%f", MEDIUM);
+ }
+ }
+
+ public void timeFormatter_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%f", LARGE);
+ }
+ }
+
+ public void timeFormatter_dot2f_small(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%.2f", SMALL);
+ }
+ }
+
+ public void timeFormatter_dot2f_medium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%.2f", MEDIUM);
+ }
+ }
+
+ public void timeFormatter_dot2f_large(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ String.format("%.2f", LARGE);
+ }
+ }
+}
diff --git a/benchmarks/regression/ReflectionBenchmark.java b/benchmarks/regression/ReflectionBenchmark.java
new file mode 100644
index 0000000..e3c7bbf
--- /dev/null
+++ b/benchmarks/regression/ReflectionBenchmark.java
@@ -0,0 +1,250 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+public class ReflectionBenchmark {
+ public void timeObject_getClass(int reps) throws Exception {
+ C c = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ c.getClass();
+ }
+ }
+
+ public void timeClass_getField(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.getField("f");
+ }
+ }
+
+ public void timeClass_getDeclaredField(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.getDeclaredField("f");
+ }
+ }
+
+ public void timeClass_getConstructor(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.getConstructor();
+ }
+ }
+
+ public void timeClass_newInstance(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Constructor constructor = klass.getConstructor();
+ for (int rep = 0; rep < reps; ++rep) {
+ constructor.newInstance();
+ }
+ }
+
+ public void timeClass_getMethod(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.getMethod("m");
+ }
+ }
+
+ public void timeClass_getDeclaredMethod(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.getDeclaredMethod("m");
+ }
+ }
+
+ public void timeField_setInt(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Field f = klass.getDeclaredField("f");
+ C instance = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ f.setInt(instance, 1);
+ }
+ }
+
+ public void timeField_getInt(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Field f = klass.getDeclaredField("f");
+ C instance = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ f.getInt(instance);
+ }
+ }
+
+ public void timeMethod_invokeV(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("m");
+ C instance = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(instance);
+ }
+ }
+
+ public void timeMethod_invokeStaticV(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("sm");
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(null);
+ }
+ }
+
+ public void timeMethod_invokeI(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("setField", int.class);
+ C instance = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(instance, 1);
+ }
+ }
+
+ public void timeMethod_invokePreBoxedI(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("setField", int.class);
+ C instance = new C();
+ Integer one = Integer.valueOf(1);
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(instance, one);
+ }
+ }
+
+ public void timeMethod_invokeStaticI(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("setStaticField", int.class);
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(null, 1);
+ }
+ }
+
+ public void timeMethod_invokeStaticPreBoxedI(int reps) throws Exception {
+ Class<?> klass = C.class;
+ Method m = klass.getDeclaredMethod("setStaticField", int.class);
+ Integer one = Integer.valueOf(1);
+ for (int rep = 0; rep < reps; ++rep) {
+ m.invoke(null, one);
+ }
+ }
+
+ public void timeRegularMethodInvocation(int reps) throws Exception {
+ C instance = new C();
+ for (int rep = 0; rep < reps; ++rep) {
+ instance.setField(1);
+ }
+ }
+
+ public void timeRegularConstructor(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ new C();
+ }
+ }
+
+ public void timeClass_classNewInstance(int reps) throws Exception {
+ Class<?> klass = C.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.newInstance();
+ }
+ }
+
+ public void timeClass_isInstance(int reps) throws Exception {
+ D d = new D();
+ Class<?> klass = IC.class;
+ for (int rep = 0; rep < reps; ++rep) {
+ klass.isInstance(d);
+ }
+ }
+
+ public void timeGetInstanceField(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ // The field here (and in timeGetStaticField) were chosen to be
+ // ~75% down the bottom of the alphabetically sorted field list.
+ // It's hard to construct a "fair" test case without resorting to
+ // a class whose field names are created algorithmically.
+ //
+ // TODO: Write a test script that generates both the classes we're
+ // reflecting on and the test case for each of its fields.
+ R.class.getField("mtextAppearanceLargePopupMenu");
+ }
+ }
+
+ public void timeGetStaticField(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ R.class.getField("weekNumberColor");
+ }
+ }
+
+ public void timeGetInterfaceStaticField(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ F.class.getField("sf");
+ }
+ }
+
+ public void timeGetSuperClassField(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ G.class.getField("f");
+ }
+ }
+
+
+ public static class C {
+ public static int sf = 0;
+ public int f = 0;
+
+ public C() {
+ // A non-empty constructor so we don't get optimized away.
+ f = 1;
+ }
+
+ public void m() {
+ }
+
+ public static void sm() {
+ }
+
+ public void setField(int value) {
+ f = value;
+ }
+
+ public static void setStaticField(int value) {
+ sf = value;
+ }
+ }
+
+ interface IA {
+ }
+
+ interface IB extends IA {
+ }
+
+ interface IC extends IB {
+ public static final int sf = 0;
+ }
+
+ class D implements IC {
+ }
+
+ class E extends D {
+ }
+
+ class F extends E implements IB {
+ }
+
+ class G extends C {
+ }
+}
diff --git a/benchmarks/regression/SSLLoopbackBenchmark.java b/benchmarks/regression/SSLLoopbackBenchmark.java
new file mode 100644
index 0000000..f88c793
--- /dev/null
+++ b/benchmarks/regression/SSLLoopbackBenchmark.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import javax.net.ssl.SSLSocket;
+import libcore.java.security.TestKeyStore;
+import libcore.javax.net.ssl.TestSSLContext;
+import libcore.javax.net.ssl.TestSSLSocketPair;
+
+public class SSLLoopbackBenchmark {
+
+ public void time(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ TestSSLContext context = TestSSLContext.create(
+ TestKeyStore.getClient(), TestKeyStore.getServer());
+ SSLSocket[] sockets = TestSSLSocketPair.connect(context, null, null);
+ context.close();
+ sockets[0].close();
+ sockets[1].close();
+ }
+ }
+}
diff --git a/benchmarks/regression/SSLSocketBenchmark.java b/benchmarks/regression/SSLSocketBenchmark.java
new file mode 100644
index 0000000..d7aa8ff
--- /dev/null
+++ b/benchmarks/regression/SSLSocketBenchmark.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.URL;
+import javax.net.SocketFactory;
+import javax.net.ssl.SSLContext;
+
+public class SSLSocketBenchmark {
+
+ private static final int BUFFER_SIZE = 8192;
+
+ final byte[] buffer = new byte[BUFFER_SIZE];
+
+ @Param private WebSite webSite;
+
+ public enum WebSite {
+ DOCS("https://docs.google.com"),
+ MAIL("https://mail.google.com"),
+ SITES("https://sites.google.com"),
+ WWW("https://www.google.com");
+ final InetAddress host;
+ final int port;
+ final byte[] request;
+ WebSite(String uri) {
+ try {
+ URL url = new URL(uri);
+
+ this.host = InetAddress.getByName(url.getHost());
+
+ int p = url.getPort();
+ String portString;
+ if (p == -1) {
+ this.port = 443;
+ portString = "";
+ } else {
+ this.port = p;
+ portString = ":" + port;
+ }
+
+ this.request = ("GET " + uri + " HTTP/1.0\r\n"
+ + "Host: " + host + portString + "\r\n"
+ +"\r\n").getBytes();
+
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private SocketFactory sf;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, null, null);
+ this.sf = sslContext.getSocketFactory();
+ }
+
+ public void time(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Socket s = sf.createSocket(webSite.host, webSite.port);
+ OutputStream out = s.getOutputStream();
+ out.write(webSite.request);
+ InputStream in = s.getInputStream();
+ while (true) {
+ int n = in.read(buffer);
+ if (n == -1) {
+ break;
+ }
+ }
+ in.close();
+ }
+ }
+}
diff --git a/benchmarks/regression/SSLSocketFactoryBenchmark.java b/benchmarks/regression/SSLSocketFactoryBenchmark.java
new file mode 100644
index 0000000..2b00c39
--- /dev/null
+++ b/benchmarks/regression/SSLSocketFactoryBenchmark.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import javax.net.ssl.SSLSocketFactory;
+
+public class SSLSocketFactoryBenchmark {
+ public void time(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ SSLSocketFactory.getDefault();
+ }
+ }
+}
diff --git a/benchmarks/regression/SchemePrefixBenchmark.java b/benchmarks/regression/SchemePrefixBenchmark.java
new file mode 100644
index 0000000..375965e
--- /dev/null
+++ b/benchmarks/regression/SchemePrefixBenchmark.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public final class SchemePrefixBenchmark {
+
+ enum Strategy {
+ JAVA() {
+ @Override String execute(String spec) {
+ int colon = spec.indexOf(':');
+
+ if (colon < 1) {
+ return null;
+ }
+
+ for (int i = 0; i < colon; i++) {
+ char c = spec.charAt(i);
+ if (!isValidSchemeChar(i, c)) {
+ return null;
+ }
+ }
+
+ return spec.substring(0, colon).toLowerCase(Locale.US);
+ }
+
+ private boolean isValidSchemeChar(int index, char c) {
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
+ return true;
+ }
+ if (index > 0 && ((c >= '0' && c <= '9') || c == '+' || c == '-' || c == '.')) {
+ return true;
+ }
+ return false;
+ }
+ },
+
+ REGEX() {
+ private final Pattern pattern = Pattern.compile("^([a-zA-Z][a-zA-Z0-9+\\-.]*):");
+
+ @Override String execute(String spec) {
+ Matcher matcher = pattern.matcher(spec);
+ if (matcher.find()) {
+ return matcher.group(1).toLowerCase(Locale.US);
+ } else {
+ return null;
+ }
+ }
+ };
+
+
+ abstract String execute(String spec);
+ }
+
+ @Param Strategy strategy;
+
+ public void timeSchemePrefix(int reps) {
+ for (int i = 0; i < reps; i++) {
+ strategy.execute("http://android.com");
+ }
+ }
+}
diff --git a/benchmarks/regression/SerializationBenchmark.java b/benchmarks/regression/SerializationBenchmark.java
new file mode 100644
index 0000000..6ff4342
--- /dev/null
+++ b/benchmarks/regression/SerializationBenchmark.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+import java.util.ArrayList;
+
+public class SerializationBenchmark {
+ private static byte[] bytes(Object o) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(o);
+ out.close();
+ return baos.toByteArray();
+ }
+
+ public void timeReadIntArray(int reps) throws Exception {
+ int[] intArray = new int[256];
+ readSingleObject(reps, intArray);
+ }
+
+ public void timeWriteIntArray(int reps) throws Exception {
+ int[] intArray = new int[256];
+ writeSingleObject(reps, intArray);
+ }
+ public void timeReadArrayListInteger(int reps) throws Exception {
+ ArrayList<Integer> object = new ArrayList<Integer>();
+ for (int i = 0; i < 256; ++i) {
+ object.add(i);
+ }
+ readSingleObject(reps, object);
+ }
+
+ public void timeWriteArrayListInteger(int reps) throws Exception {
+ ArrayList<Integer> object = new ArrayList<Integer>();
+ for (int i = 0; i < 256; ++i) {
+ object.add(i);
+ }
+ writeSingleObject(reps, object);
+ }
+
+ public void timeReadString(int reps) throws Exception {
+ readSingleObject(reps, "hello");
+ }
+
+ public void timeReadObjectStreamClass(int reps) throws Exception {
+ // A special case because serialization itself requires this class.
+ // (This should really be a unit test.)
+ ObjectStreamClass osc = ObjectStreamClass.lookup(String.class);
+ readSingleObject(reps, osc);
+ }
+
+ public void timeWriteString(int reps) throws Exception {
+ // String is a special case that avoids JNI.
+ writeSingleObject(reps, "hello");
+ }
+
+ public void timeWriteObjectStreamClass(int reps) throws Exception {
+ // A special case because serialization itself requires this class.
+ // (This should really be a unit test.)
+ ObjectStreamClass osc = ObjectStreamClass.lookup(String.class);
+ writeSingleObject(reps, osc);
+ }
+
+ // This is a baseline for the others.
+ public void timeWriteNoObjects(int reps) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ for (int rep = 0; rep < reps; ++rep) {
+ out.reset();
+ baos.reset();
+ }
+ out.close();
+ }
+
+ private void readSingleObject(int reps, Object object) throws Exception {
+ byte[] bytes = bytes(object);
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ for (int rep = 0; rep < reps; ++rep) {
+ ObjectInputStream in = new ObjectInputStream(bais);
+ in.readObject();
+ in.close();
+ bais.reset();
+ }
+ }
+
+ private void writeSingleObject(int reps, Object o) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ for (int rep = 0; rep < reps; ++rep) {
+ out.writeObject(o);
+ out.reset();
+ baos.reset();
+ }
+ out.close();
+ }
+
+ public void timeWriteEveryKindOfField(int reps) throws Exception {
+ writeSingleObject(reps, new LittleBitOfEverything());
+ }
+ public void timeWriteSerializableBoolean(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableBoolean());
+ }
+ public void timeWriteSerializableByte(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableByte());
+ }
+ public void timeWriteSerializableChar(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableChar());
+ }
+ public void timeWriteSerializableDouble(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableDouble());
+ }
+ public void timeWriteSerializableFloat(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableFloat());
+ }
+ public void timeWriteSerializableInt(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableInt());
+ }
+ public void timeWriteSerializableLong(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableLong());
+ }
+ public void timeWriteSerializableShort(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableShort());
+ }
+ public void timeWriteSerializableReference(int reps) throws Exception {
+ writeSingleObject(reps, new SerializableReference());
+ }
+
+ public void timeReadEveryKindOfField(int reps) throws Exception {
+ readSingleObject(reps, new LittleBitOfEverything());
+ }
+ public void timeReadSerializableBoolean(int reps) throws Exception {
+ readSingleObject(reps, new SerializableBoolean());
+ }
+ public void timeReadSerializableByte(int reps) throws Exception {
+ readSingleObject(reps, new SerializableByte());
+ }
+ public void timeReadSerializableChar(int reps) throws Exception {
+ readSingleObject(reps, new SerializableChar());
+ }
+ public void timeReadSerializableDouble(int reps) throws Exception {
+ readSingleObject(reps, new SerializableDouble());
+ }
+ public void timeReadSerializableFloat(int reps) throws Exception {
+ readSingleObject(reps, new SerializableFloat());
+ }
+ public void timeReadSerializableInt(int reps) throws Exception {
+ readSingleObject(reps, new SerializableInt());
+ }
+ public void timeReadSerializableLong(int reps) throws Exception {
+ readSingleObject(reps, new SerializableLong());
+ }
+ public void timeReadSerializableShort(int reps) throws Exception {
+ readSingleObject(reps, new SerializableShort());
+ }
+ public void timeReadSerializableReference(int reps) throws Exception {
+ readSingleObject(reps, new SerializableReference());
+ }
+
+ public static class SerializableBoolean implements Serializable {
+ boolean z;
+ }
+ public static class SerializableByte implements Serializable {
+ byte b;
+ }
+ public static class SerializableChar implements Serializable {
+ char c;
+ }
+ public static class SerializableDouble implements Serializable {
+ double d;
+ }
+ public static class SerializableFloat implements Serializable {
+ float f;
+ }
+ public static class SerializableInt implements Serializable {
+ int i;
+ }
+ public static class SerializableLong implements Serializable {
+ long j;
+ }
+ public static class SerializableShort implements Serializable {
+ short s;
+ }
+ public static class SerializableReference implements Serializable {
+ Object l;
+ }
+
+ public static class LittleBitOfEverything implements Serializable {
+ boolean z;
+ byte b;
+ char c;
+ double d;
+ float f;
+ int i;
+ long j;
+ short s;
+ Object l;
+ }
+}
diff --git a/benchmarks/regression/SignatureBenchmark.java b/benchmarks/regression/SignatureBenchmark.java
new file mode 100644
index 0000000..e7a3c80
--- /dev/null
+++ b/benchmarks/regression/SignatureBenchmark.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.Signature;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tests RSA and DSA signature creation and verification.
+ */
+public class SignatureBenchmark {
+
+ private static final int DATA_SIZE = 8192;
+ private static final byte[] DATA = new byte[DATA_SIZE];
+ static {
+ for (int i = 0; i < DATA_SIZE; i++) {
+ DATA[i] = (byte)i;
+ }
+ }
+ @Param private Algorithm algorithm;
+
+ public enum Algorithm {
+ MD5WithRSA,
+ SHA1WithRSA,
+ SHA256WithRSA,
+ SHA384WithRSA,
+ SHA512WithRSA,
+ SHA1withDSA
+ };
+
+ @Param private Implementation implementation;
+
+ public enum Implementation { OpenSSL, BouncyCastle };
+
+ // Key generation and signing aren't part of the benchmark for verification
+ // so cache the results
+ private static Map<String,KeyPair> KEY_PAIRS = new HashMap<String,KeyPair>();
+ private static Map<String,byte[]> SIGNATURES = new HashMap<String,byte[]>();
+
+ private String signatureAlgorithm;
+ private byte[] signature;
+ private PrivateKey privateKey;
+ private PublicKey publicKey;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ this.signatureAlgorithm = algorithm.toString();
+
+ String keyAlgorithm = signatureAlgorithm.substring(signatureAlgorithm.length() - 3 ,
+ signatureAlgorithm.length());
+ KeyPair keyPair = KEY_PAIRS.get(keyAlgorithm);
+ if (keyPair == null) {
+ KeyPairGenerator generator = KeyPairGenerator.getInstance(keyAlgorithm);
+ keyPair = generator.generateKeyPair();
+ KEY_PAIRS.put(keyAlgorithm, keyPair);
+ }
+ this.privateKey = keyPair.getPrivate();
+ this.publicKey = keyPair.getPublic();
+
+ this.signature = SIGNATURES.get(signatureAlgorithm);
+ if (this.signature == null) {
+ Signature signer = Signature.getInstance(signatureAlgorithm);
+ signer.initSign(keyPair.getPrivate());
+ signer.update(DATA);
+ this.signature = signer.sign();
+ SIGNATURES.put(signatureAlgorithm, signature);
+ }
+ }
+
+ public void timeSign(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Signature signer;
+ switch (implementation) {
+ case OpenSSL:
+ signer = Signature.getInstance(signatureAlgorithm, "AndroidOpenSSL");
+ break;
+ case BouncyCastle:
+ signer = Signature.getInstance(signatureAlgorithm, "BC");
+ break;
+ default:
+ throw new RuntimeException(implementation.toString());
+ }
+ signer.initSign(privateKey);
+ signer.update(DATA);
+ signer.sign();
+ }
+ }
+
+ public void timeVerify(int reps) throws Exception {
+ for (int i = 0; i < reps; ++i) {
+ Signature verifier;
+ switch (implementation) {
+ case OpenSSL:
+ verifier = Signature.getInstance(signatureAlgorithm, "AndroidOpenSSL");
+ break;
+ case BouncyCastle:
+ verifier = Signature.getInstance(signatureAlgorithm, "BC");
+ break;
+ default:
+ throw new RuntimeException(implementation.toString());
+ }
+ verifier.initVerify(publicKey);
+ verifier.update(DATA);
+ verifier.verify(signature);
+ }
+ }
+}
diff --git a/benchmarks/regression/SimpleDateFormatBenchmark.java b/benchmarks/regression/SimpleDateFormatBenchmark.java
new file mode 100644
index 0000000..b9becc7
--- /dev/null
+++ b/benchmarks/regression/SimpleDateFormatBenchmark.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package benchmarks.regression;
+
+import android.icu.text.TimeZoneNames;
+
+import java.text.DateFormatSymbols;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ * Benchmark for java.text.SimpleDateFormat. This tests common formatting, parsing and creation
+ * operations with a specific focus on TimeZone handling.
+ */
+public class SimpleDateFormatBenchmark {
+ public void time_createFormatWithTimeZone(int reps) {
+ for (int i = 0; i < reps; i++) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z");
+ }
+ }
+
+ public void time_parseWithTimeZoneShort(int reps) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z");
+ for (int i = 0; i < reps; i++) {
+ sdf.parse("2000.01.01 PST");
+ }
+ }
+
+ public void time_parseWithTimeZoneLong(int reps) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz");
+ for (int i = 0; i < reps; i++) {
+ sdf.parse("2000.01.01 Pacific Standard Time");
+ }
+ }
+
+ public void time_parseWithoutTimeZone(int reps) throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
+ for (int i = 0; i < reps; i++) {
+ sdf.parse("2000.01.01");
+ }
+ }
+
+ public void time_createAndParseWithTimeZoneShort(int reps) throws ParseException {
+ for (int i = 0; i < reps; i++) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z");
+ sdf.parse("2000.01.01 PST");
+ }
+ }
+
+ public void time_createAndParseWithTimeZoneLong(int reps) throws ParseException {
+ for (int i = 0; i < reps; i++) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz");
+ sdf.parse("2000.01.01 Pacific Standard Time");
+ }
+ }
+
+ public void time_formatWithTimeZoneShort(int reps) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd z");
+ for (int i = 0; i < reps; i++) {
+ sdf.format(new Date());
+ }
+ }
+
+ public void time_formatWithTimeZoneLong(int reps) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz");
+ for (int i = 0; i < reps; i++) {
+ sdf.format(new Date());
+ }
+ }
+
+ /**
+ * Times first-time execution to measure effects of initial loading of data that's lost in
+ * full caliper benchmarks.
+ */
+ public static void main(String[] args) throws ParseException {
+ long start, end;
+
+ Locale locale = Locale.GERMAN;
+ start = System.nanoTime();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd zzzz", locale);
+ end = System.nanoTime();
+ System.out.printf("Creating first SDF: %,d ns\n", end-start);
+
+ // N code had special cases for currently-set and for default timezone. We want to measure
+ // the generic case.
+ sdf.setTimeZone(TimeZone.getTimeZone("Hongkong"));
+
+ start = System.nanoTime();
+ sdf.parse("2000.1.1 Kubanische Normalzeit");
+ end = System.nanoTime();
+ System.out.printf("First parse: %,d ns\n", end-start);
+
+ start = System.nanoTime();
+ sdf.format(new Date());
+ end = System.nanoTime();
+ System.out.printf("First format: %,d ns\n", end-start);
+ }
+}
diff --git a/benchmarks/regression/StrictMathBenchmark.java b/benchmarks/regression/StrictMathBenchmark.java
new file mode 100644
index 0000000..0dcf882
--- /dev/null
+++ b/benchmarks/regression/StrictMathBenchmark.java
@@ -0,0 +1,386 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+/**
+ * Many of these tests are bogus in that the cost will vary wildly depending on inputs.
+ * For _my_ current purposes, that's okay. But beware!
+ */
+public class StrictMathBenchmark {
+ private final double d = 1.2;
+ private final float f = 1.2f;
+ private final int i = 1;
+ private final long l = 1L;
+
+ /* Values for full line coverage of ceiling function */
+ private static final double[] CEIL_DOUBLES = new double[] {
+ 3245817.2018463886,
+ 1418139.083668501,
+ 3.572936802189103E15,
+ -4.7828929737254625E249,
+ 213596.58636369856,
+ 6.891928421440976E-96,
+ -7.9318566885477E-36,
+ -1.9610339084804148E15,
+ -4.696725715628246E10,
+ 3742491.296880909,
+ 7.140274745333553E11
+ };
+
+ /* Values for full line coverage of floor function */
+ private static final double[] FLOOR_DOUBLES = new double[] {
+ 7.140274745333553E11,
+ 3742491.296880909,
+ -4.696725715628246E10,
+ -1.9610339084804148E15,
+ 7.049948629370372E-56,
+ -7.702933170334643E-16,
+ -1.99657681810579,
+ -1.1659287182288336E236,
+ 4.085518816513057E15,
+ -1500948.440658056,
+ -2.2316479921415575E7
+ };
+
+ public void timeAbsD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.abs(d);
+ }
+ }
+
+ public void timeAbsF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.abs(f);
+ }
+ }
+
+ public void timeAbsI(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.abs(i);
+ }
+ }
+
+ public void timeAbsL(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.abs(l);
+ }
+ }
+
+ public void timeAcos(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.acos(d);
+ }
+ }
+
+ public void timeAsin(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.asin(d);
+ }
+ }
+
+ public void timeAtan(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.atan(d);
+ }
+ }
+
+ public void timeAtan2(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.atan2(3, 4);
+ }
+ }
+
+ public void timeCbrt(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.cbrt(d);
+ }
+ }
+
+ public void timeCeilOverInterestingValues(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < CEIL_DOUBLES.length; ++i) {
+ StrictMath.ceil(CEIL_DOUBLES[i]);
+ }
+ }
+ }
+
+ public void timeCopySignD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.copySign(d, d);
+ }
+ }
+
+ public void timeCopySignF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.copySign(f, f);
+ }
+ }
+
+ public void timeCos(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.cos(d);
+ }
+ }
+
+ public void timeCosh(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.cosh(d);
+ }
+ }
+
+ public void timeExp(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.exp(d);
+ }
+ }
+
+ public void timeExpm1(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.expm1(d);
+ }
+ }
+
+ public void timeFloorOverInterestingValues(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < FLOOR_DOUBLES.length; ++i) {
+ StrictMath.floor(FLOOR_DOUBLES[i]);
+ }
+ }
+ }
+
+ public void timeGetExponentD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.getExponent(d);
+ }
+ }
+
+ public void timeGetExponentF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.getExponent(f);
+ }
+ }
+
+ public void timeHypot(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.hypot(d, d);
+ }
+ }
+
+ public void timeIEEEremainder(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.IEEEremainder(d, d);
+ }
+ }
+
+ public void timeLog(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.log(d);
+ }
+ }
+
+ public void timeLog10(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.log10(d);
+ }
+ }
+
+ public void timeLog1p(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.log1p(d);
+ }
+ }
+
+ public void timeMaxD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.max(d, d);
+ }
+ }
+
+ public void timeMaxF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.max(f, f);
+ }
+ }
+
+ public void timeMaxI(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.max(i, i);
+ }
+ }
+
+ public void timeMaxL(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.max(l, l);
+ }
+ }
+
+ public void timeMinD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.min(d, d);
+ }
+ }
+
+ public void timeMinF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.min(f, f);
+ }
+ }
+
+ public void timeMinI(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.min(i, i);
+ }
+ }
+
+ public void timeMinL(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.min(l, l);
+ }
+ }
+
+ public void timeNextAfterD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.nextAfter(d, d);
+ }
+ }
+
+ public void timeNextAfterF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.nextAfter(f, f);
+ }
+ }
+
+ public void timeNextUpD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.nextUp(d);
+ }
+ }
+
+ public void timeNextUpF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.nextUp(f);
+ }
+ }
+
+ public void timePow(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.pow(d, d);
+ }
+ }
+
+ public void timeRandom(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.random();
+ }
+ }
+
+ public void timeRint(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.rint(d);
+ }
+ }
+
+ public void timeRoundD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.round(d);
+ }
+ }
+
+ public void timeRoundF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.round(f);
+ }
+ }
+
+ public void timeScalbD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.scalb(d, 5);
+ }
+ }
+
+ public void timeScalbF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.scalb(f, 5);
+ }
+ }
+
+ public void timeSignumD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.signum(d);
+ }
+ }
+
+ public void timeSignumF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.signum(f);
+ }
+ }
+
+ public void timeSin(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.sin(d);
+ }
+ }
+
+ public void timeSinh(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.sinh(d);
+ }
+ }
+
+ public void timeSqrt(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.sqrt(d);
+ }
+ }
+
+ public void timeTan(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.tan(d);
+ }
+ }
+
+ public void timeTanh(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.tanh(d);
+ }
+ }
+
+ public void timeToDegrees(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.toDegrees(d);
+ }
+ }
+
+ public void timeToRadians(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.toRadians(d);
+ }
+ }
+
+ public void timeUlpD(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.ulp(d);
+ }
+ }
+
+ public void timeUlpF(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ StrictMath.ulp(f);
+ }
+ }
+}
diff --git a/benchmarks/regression/StringBenchmark.java b/benchmarks/regression/StringBenchmark.java
new file mode 100644
index 0000000..dc425c3
--- /dev/null
+++ b/benchmarks/regression/StringBenchmark.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+public class StringBenchmark {
+ enum StringLengths {
+ EMPTY(""),
+ SHORT("short"),
+ EIGHTY(makeString(80)),
+ EIGHT_KI(makeString(8192));
+ final String value;
+ private StringLengths(String value) { this.value = value; }
+ }
+ @Param private StringLengths s;
+
+ private static String makeString(int length) {
+ StringBuilder result = new StringBuilder(length);
+ for (int i = 0; i < length; ++i) {
+ result.append((char) i);
+ }
+ return result.toString();
+ }
+
+ public void timeHashCode(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.hashCode();
+ }
+ }
+}
diff --git a/benchmarks/regression/StringBuilderBenchmark.java b/benchmarks/regression/StringBuilderBenchmark.java
new file mode 100644
index 0000000..ef54432
--- /dev/null
+++ b/benchmarks/regression/StringBuilderBenchmark.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+/**
+ * Tests the performance of various StringBuilder methods.
+ */
+public class StringBuilderBenchmark {
+
+ @Param({"1", "10", "100"}) private int length;
+
+ public void timeAppendBoolean(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(true);
+ }
+ }
+ }
+
+ public void timeAppendChar(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append('c');
+ }
+ }
+ }
+
+ public void timeAppendCharArray(int reps) {
+ char[] chars = "chars".toCharArray();
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(chars);
+ }
+ }
+ }
+
+ public void timeAppendCharSequence(int reps) {
+ CharSequence cs = "chars";
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(cs);
+ }
+ }
+ }
+
+ public void timeAppendSubCharSequence(int reps) {
+ CharSequence cs = "chars";
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(cs);
+ }
+ }
+ }
+
+ public void timeAppendDouble(int reps) {
+ double d = 1.2;
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(d);
+ }
+ }
+ }
+
+ public void timeAppendFloat(int reps) {
+ float f = 1.2f;
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(f);
+ }
+ }
+ }
+
+ public void timeAppendInt(int reps) {
+ int n = 123;
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(n);
+ }
+ }
+ }
+
+ public void timeAppendLong(int reps) {
+ long l = 123;
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(l);
+ }
+ }
+ }
+
+ public void timeAppendObject(int reps) {
+ // We don't want to time the toString, so ensure we're calling a trivial one...
+ Object o = new Object() {
+ @Override public String toString() {
+ return "constant";
+ }
+ };
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(o);
+ }
+ }
+ }
+
+ public void timeAppendString(int reps) {
+ String s = "chars";
+ for (int i = 0; i < reps; ++i) {
+ StringBuilder sb = new StringBuilder();
+ for (int j = 0; j < length; ++j) {
+ sb.append(s);
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/StringEqualsBenchmark.java b/benchmarks/regression/StringEqualsBenchmark.java
new file mode 100644
index 0000000..db19b25
--- /dev/null
+++ b/benchmarks/regression/StringEqualsBenchmark.java
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 2015 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import junit.framework.Assert;
+
+/**
+ * Benchmarks to measure the performance of String.equals for Strings of varying lengths.
+ * Each benchmarks makes 5 measurements, aiming at covering cases like strings of equal length
+ * that are not equal, identical strings with different references, strings with different endings,
+ * interned strings, and strings of different lengths.
+ */
+public class StringEqualsBenchmark {
+ private final String long1 = "Ahead-of-time compilation is possible as the compiler may just"
+ + "convert an instruction thus: dex code: add-int v1000, v2000, v3000 C code: setIntRegter"
+ + "(1000, call_dex_add_int(getIntRegister(2000), getIntRegister(3000)) This means even lid"
+ + "instructions may have code generated, however, it is not expected that code generate in"
+ + "this way will perform well. The job of AOT verification is to tell the compiler that"
+ + "instructions are sound and provide tests to detect unsound sequences so slow path code"
+ + "may be generated. Other than for totally invalid code, the verification may fail at AOr"
+ + "run-time. At AOT time it can be because of incomplete information, at run-time it can e"
+ + "that code in a different apk that the application depends upon has changed. The Dalvik"
+ + "verifier would return a bool to state whether a Class were good or bad. In ART the fail"
+ + "case becomes either a soft or hard failure. Classes have new states to represent that a"
+ + "soft failure occurred at compile time and should be re-verified at run-time.";
+
+ private final String veryLong = "Garbage collection has two phases. The first distinguishes"
+ + "live objects from garbage objects. The second is reclaiming the rage of garbage object"
+ + "In the mark-sweep algorithm used by Dalvik, the first phase is achievd by computing the"
+ + "closure of all reachable objects in a process known as tracing from theoots. After the"
+ + "trace has completed, garbage objects are reclaimed. Each of these operations can be"
+ + "parallelized and can be interleaved with the operation of the applicationTraditionally,"
+ + "the tracing phase dominates the time spent in garbage collection. The greatreduction i"
+ + "pause time can be achieved by interleaving as much of this phase as possible with the"
+ + "application. If we simply ran the GC in a separate thread with no other changes, normal"
+ + "operation of an application would confound the trace. Abstractly, the GC walks the h o"
+ + "all reachable objects. When the application is paused, the object graph cannot change."
+ + "The GC can therefore walk this structure and assume that all reachable objects live."
+ + "When the application is running, this graph may be altered. New nodes may be addnd edge"
+ + "may be changed. These changes may cause live objects to be hidden and falsely recla by"
+ + "the GC. To avoid this problem a write barrier is used to intercept and record modifion"
+ + "to objects in a separate structure. After performing its walk, the GC will revisit the"
+ + "updated objects and re-validate its assumptions. Without a card table, the garbage"
+ + "collector would have to visit all objects reached during the trace looking for dirtied"
+ + "objects. The cost of this operation would be proportional to the amount of live data."
+ + "With a card table, the cost of this operation is proportional to the amount of updateat"
+ + "The write barrier in Dalvik is a card marking write barrier. Card marking is the proce"
+ + "of noting the location of object connectivity changes on a sub-page granularity. A car"
+ + "is merely a colorful term for a contiguous extent of memory smaller than a page, common"
+ + "somewhere between 128- and 512-bytes. Card marking is implemented by instrumenting all"
+ + "locations in the virtual machine which can assign a pointer to an object. After themal"
+ + "pointer assignment has occurred, a byte is written to a byte-map spanning the heap whic"
+ + "corresponds to the location of the updated object. This byte map is known as a card ta"
+ + "The garbage collector visits this card table and looks for written bytes to reckon the"
+ + "location of updated objects. It then rescans all objects located on the dirty card,"
+ + "correcting liveness assumptions that were invalidated by the application. While card"
+ + "marking imposes a small burden on the application outside of a garbage collection, the"
+ + "overhead of maintaining the card table is paid for by the reduced time spent inside"
+ + "garbage collection. With the concurrent garbage collection thread and a write barrier"
+ + "supported by the interpreter, JIT, and Runtime we modify garbage collection";
+
+ private final String[][] shortStrings = new String[][] {
+ // Equal, constant comparison
+ { "a", "a" },
+ // Different constants, first character different
+ { ":", " :"},
+ // Different constants, last character different, same length
+ { "ja M", "ja N"},
+ // Different constants, different lengths
+ {"$$$", "$$"},
+ // Force execution of code beyond reference equality check
+ {"hi", new String("hi")}
+ };
+
+ private final String[][] mediumStrings = new String[][] {
+ // Equal, constant comparison
+ { "Hello my name is ", "Hello my name is " },
+ // Different constants, different lengths
+ { "What's your name?", "Whats your name?" },
+ // Force execution of code beyond reference equality check
+ { "Android Runtime", new String("Android Runtime") },
+ // Different constants, last character different, same length
+ { "v3ry Cre@tiVe?****", "v3ry Cre@tiVe?***." },
+ // Different constants, first character different, same length
+ { "!@#$%^&*()_++*^$#@", "0@#$%^&*()_++*^$#@" }
+ };
+
+ private final String[][] longStrings = new String[][] {
+ // Force execution of code beyond reference equality check
+ { long1, new String(long1) },
+ // Different constants, last character different, same length
+ { long1 + "fun!", long1 + "----" },
+ // Equal, constant comparison
+ { long1 + long1, long1 + long1 },
+ // Different constants, different lengths
+ { long1 + "123456789", long1 + "12345678" },
+ // Different constants, first character different, same length
+ { "Android Runtime" + long1, "android Runtime" + long1 }
+ };
+
+ private final String[][] veryLongStrings = new String[][] {
+ // Force execution of code beyond reference equality check
+ { veryLong, new String(veryLong) },
+ // Different constants, different lengths
+ { veryLong + veryLong, veryLong + " " + veryLong },
+ // Equal, constant comparison
+ { veryLong + veryLong + veryLong, veryLong + veryLong + veryLong },
+ // Different constants, last character different, same length
+ { veryLong + "77777", veryLong + "99999" },
+ // Different constants, first character different
+ { "Android Runtime" + veryLong, "android Runtime" + veryLong }
+ };
+
+ private final String[][] endStrings = new String[][] {
+ // Different constants, medium but different lengths
+ { "Hello", "Hello " },
+ // Different constants, long but different lengths
+ { long1, long1 + "x"},
+ // Different constants, very long but different lengths
+ { veryLong, veryLong + "?"},
+ // Different constants, same medium lengths
+ { "How are you doing today?", "How are you doing today " },
+ // Different constants, short but different lengths
+ { "1", "1." }
+ };
+
+ private final String tmpStr1 = "012345678901234567890"
+ + "0123456789012345678901234567890123456789"
+ + "0123456789012345678901234567890123456789"
+ + "0123456789012345678901234567890123456789"
+ + "0123456789012345678901234567890123456789";
+
+ private final String tmpStr2 = "z012345678901234567890"
+ + "0123456789012345678901234567890123456789"
+ + "0123456789012345678901234567890123456789"
+ + "0123456789012345678901234567890123456789"
+ + "012345678901234567890123456789012345678x";
+
+ private final String[][] nonalignedStrings = new String[][] {
+ // Different non-word aligned medium length strings
+ { tmpStr1, tmpStr1.substring(1) },
+ // Different differently non-word aligned medium length strings
+ { tmpStr2, tmpStr2.substring(2) },
+ // Different non-word aligned long length strings
+ { long1, long1.substring(3) },
+ // Different non-word aligned very long length strings
+ { veryLong, veryLong.substring(1) },
+ // Equal non-word aligned constant strings
+ { "hello", "hello".substring(1) }
+ };
+
+ private final Object[] objects = new Object[] {
+ // Compare to Double object
+ new Double(1.5),
+ // Compare to Integer object
+ new Integer(9999999),
+ // Compare to String array
+ new String[] {"h", "i"},
+ // Compare to int array
+ new int[] {1, 2, 3},
+ // Compare to Character object
+ new Character('a')
+ };
+
+ // Check assumptions about how the compiler, new String(String), and String.intern() work.
+ // Any failures here would invalidate these benchmarks.
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ // String constants are the same object
+ Assert.assertSame("abc", "abc");
+ // new String(String) makes a copy
+ Assert.assertNotSame("abc" , new String("abc"));
+ // Interned strings are treated like constants, so it is not necessary to
+ // separately benchmark interned strings.
+ Assert.assertSame("abc", "abc".intern());
+ Assert.assertSame("abc", new String("abc").intern());
+ // Compiler folds constant strings into new constants
+ Assert.assertSame(long1 + long1, long1 + long1);
+ }
+
+ // Benchmark cases of String.equals(null)
+ public void timeEqualsNull(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < mediumStrings.length; i++) {
+ mediumStrings[i][0].equals(null);
+ }
+ }
+ }
+
+ // Benchmark cases with very short (<5 character) Strings
+ public void timeEqualsShort(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < shortStrings.length; i++) {
+ shortStrings[i][0].equals(shortStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases with medium length (10-15 character) Strings
+ public void timeEqualsMedium(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < mediumStrings.length; i++) {
+ mediumStrings[i][0].equals(mediumStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases with long (>100 character) Strings
+ public void timeEqualsLong(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < longStrings.length; i++) {
+ longStrings[i][0].equals(longStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases with very long (>1000 character) Strings
+ public void timeEqualsVeryLong(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < veryLongStrings.length; i++) {
+ veryLongStrings[i][0].equals(veryLongStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases with non-word aligned Strings
+ public void timeEqualsNonWordAligned(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < nonalignedStrings.length; i++) {
+ nonalignedStrings[i][0].equals(nonalignedStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases with slight differences in the endings
+ public void timeEqualsEnd(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < endStrings.length; i++) {
+ endStrings[i][0].equals(endStrings[i][1]);
+ }
+ }
+ }
+
+ // Benchmark cases of comparing a string to a non-string object
+ public void timeEqualsNonString(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ for (int i = 0; i < mediumStrings.length; i++) {
+ mediumStrings[i][0].equals(objects[i]);
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/StringIsEmptyBenchmark.java b/benchmarks/regression/StringIsEmptyBenchmark.java
new file mode 100644
index 0000000..4be478e
--- /dev/null
+++ b/benchmarks/regression/StringIsEmptyBenchmark.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class StringIsEmptyBenchmark {
+ public void timeIsEmpty_NonEmpty(int reps) {
+ boolean result = true;
+ for (int i = 0; i < reps; ++i) {
+ result &= !("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".isEmpty());
+ }
+ if (!result) throw new RuntimeException();
+ }
+
+ public void timeIsEmpty_Empty(int reps) {
+ boolean result = true;
+ for (int i = 0; i < reps; ++i) {
+ result &= ("".isEmpty());
+ }
+ if (!result) throw new RuntimeException();
+ }
+
+ public void timeLengthEqualsZero(int reps) {
+ boolean result = true;
+ for (int i = 0; i < reps; ++i) {
+ result &= !("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".length() == 0);
+ }
+ if (!result) throw new RuntimeException();
+ }
+
+ public void timeEqualsEmpty(int reps) {
+ boolean result = true;
+ for (int i = 0; i < reps; ++i) {
+ result &= !"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".equals("");
+ }
+ if (!result) throw new RuntimeException();
+ }
+}
diff --git a/benchmarks/regression/StringLengthBenchmark.java b/benchmarks/regression/StringLengthBenchmark.java
new file mode 100644
index 0000000..104103a
--- /dev/null
+++ b/benchmarks/regression/StringLengthBenchmark.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class StringLengthBenchmark {
+ public void timeLength(int reps) {
+ int length = 0;
+ for (int i = 0; i < reps; ++i) {
+ length = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".length();
+ }
+ if (length != 51) throw new RuntimeException();
+ }
+}
diff --git a/benchmarks/regression/StringReplaceAllBenchmark.java b/benchmarks/regression/StringReplaceAllBenchmark.java
new file mode 100644
index 0000000..73e7979
--- /dev/null
+++ b/benchmarks/regression/StringReplaceAllBenchmark.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+public class StringReplaceAllBenchmark {
+ // NOTE: These estimates of MOVEABLE / NON_MOVEABLE are based on a knowledge of
+ // ART implementation details. They make a difference here because JNI calls related
+ // to strings took different paths depending on whether the String in question was
+ // moveable or not.
+ enum StringLengths {
+ EMPTY(""),
+ MOVEABLE_16(makeString(16)),
+ MOVEABLE_256(makeString(256)),
+ MOVEABLE_1024(makeString(1024)),
+ NON_MOVEABLE(makeString(64 * 1024)),
+ BOOT_IMAGE(java.util.jar.JarFile.MANIFEST_NAME);
+
+ private final String value;
+
+ StringLengths(String s) {
+ this.value = s;
+ }
+ }
+
+ private static final String makeString(int length) {
+ final String sequence8 = "abcdefghijklmnop";
+ final int numAppends = (length / 16) - 1;
+ StringBuilder stringBuilder = new StringBuilder(length);
+
+ // (n-1) occurences of "abcdefghijklmnop"
+ for (int i = 0; i < numAppends; ++i) {
+ stringBuilder.append(sequence8);
+ }
+
+ // and one final occurence of qrstuvwx.
+ stringBuilder.append("qrstuvwx");
+
+ return stringBuilder.toString();
+ }
+
+ @Param private StringLengths s;
+
+ public void timeReplaceAllTrivialPatternNonExistent(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replaceAll("fish", "0");
+ }
+ }
+
+ public void timeReplaceTrivialPatternAllRepeated(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replaceAll("jklm", "0");
+ }
+ }
+
+ public void timeReplaceAllTrivialPatternSingleOccurence(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replaceAll("qrst", "0");
+ }
+ }
+}
diff --git a/benchmarks/regression/StringReplaceBenchmark.java b/benchmarks/regression/StringReplaceBenchmark.java
new file mode 100644
index 0000000..a527633
--- /dev/null
+++ b/benchmarks/regression/StringReplaceBenchmark.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+public class StringReplaceBenchmark {
+ static enum StringLengths {
+ EMPTY(""),
+ L_16(makeString(16)),
+ L_64(makeString(64)),
+ L_256(makeString(256)),
+ L_512(makeString(512));
+
+ private final String value;
+
+ private StringLengths(String s) {
+ this.value = s;
+ }
+ }
+
+ private static final String makeString(int length) {
+ final String sequence8 = "abcdefghijklmnop";
+ final int numAppends = (length / 16) - 1;
+ StringBuilder stringBuilder = new StringBuilder(length);
+
+ // (n-1) occurences of "abcdefghijklmnop"
+ for (int i = 0; i < numAppends; ++i) {
+ stringBuilder.append(sequence8);
+ }
+
+ // and one final occurence of qrstuvwx.
+ stringBuilder.append("qrstuvwx");
+
+ return stringBuilder.toString();
+ }
+
+ @Param private StringLengths s;
+
+ public void timeReplaceCharNonExistent(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace('z', '0');
+ }
+ }
+
+ public void timeReplaceCharRepeated(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace('a', '0');
+ }
+ }
+
+ public void timeReplaceSingleChar(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace('q', '0');
+ }
+ }
+
+ public void timeReplaceSequenceNonExistent(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace("fish", "0");
+ }
+ }
+
+ public void timeReplaceSequenceRepeated(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace("jklm", "0");
+ }
+ }
+
+ public void timeReplaceSingleSequence(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ s.value.replace("qrst", "0");
+ }
+ }
+}
diff --git a/benchmarks/regression/StringSplitBenchmark.java b/benchmarks/regression/StringSplitBenchmark.java
new file mode 100644
index 0000000..7c747cf
--- /dev/null
+++ b/benchmarks/regression/StringSplitBenchmark.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.util.regex.Pattern;
+
+public class StringSplitBenchmark {
+ public void timeStringSplitComma(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ "this,is,a,simple,example".split(",");
+ }
+ }
+
+ public void timeStringSplitLiteralDot(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ "this.is.a.simple.example".split("\\.");
+ }
+ }
+
+ public void timeStringSplitNewline(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ "this\nis\na\nsimple\nexample\n".split("\n");
+ }
+ }
+
+ public void timePatternSplitComma(int reps) {
+ Pattern p = Pattern.compile(",");
+ for (int i = 0; i < reps; ++i) {
+ p.split("this,is,a,simple,example");
+ }
+ }
+
+ public void timePatternSplitLiteralDot(int reps) {
+ Pattern p = Pattern.compile("\\.");
+ for (int i = 0; i < reps; ++i) {
+ p.split("this.is.a.simple.example");
+ }
+ }
+
+ public void timeStringSplitHard(int reps) {
+ for (int i = 0; i < reps; ++i) {
+ "this,is,a,harder,example".split("[,]");
+ }
+ }
+}
diff --git a/benchmarks/regression/StringToBytesBenchmark.java b/benchmarks/regression/StringToBytesBenchmark.java
new file mode 100644
index 0000000..f43b32e
--- /dev/null
+++ b/benchmarks/regression/StringToBytesBenchmark.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+import java.nio.charset.StandardCharsets;
+
+public class StringToBytesBenchmark {
+ static enum StringLengths {
+ EMPTY(""),
+ L_16(makeString(16)),
+ L_64(makeString(64)),
+ L_256(makeString(256)),
+ L_512(makeString(512)),
+ A_16(makeAsciiString(16)),
+ A_64(makeAsciiString(64)),
+ A_256(makeAsciiString(256)),
+ A_512(makeAsciiString(512));
+
+ private final String value;
+
+ private StringLengths(String s) {
+ this.value = s;
+ }
+ }
+
+ private static final String makeString(int length) {
+ char[] chars = new char[length];
+ for (int i = 0; i < length; ++i) {
+ chars[i] = (char) i;
+ }
+ return new String(chars);
+ }
+
+ private static final String makeAsciiString(int length) {
+ char[] chars = new char[length];
+ for (int i = 0; i < length; ++i) {
+ chars[i] = ((i & 0x7f) != 0) ? (char) (i & 0x7f) : '?';
+ }
+ return new String(chars);
+ }
+
+ @Param StringLengths string;
+
+ public void timeGetBytesUtf8(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ string.value.getBytes(StandardCharsets.UTF_8);
+ }
+ }
+
+ public void timeGetBytesIso88591(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ string.value.getBytes(StandardCharsets.ISO_8859_1);
+ }
+ }
+
+ public void timeGetBytesAscii(int nreps) {
+ for (int i = 0; i < nreps; ++i) {
+ string.value.getBytes(StandardCharsets.US_ASCII);
+ }
+ }
+}
diff --git a/benchmarks/regression/StringToRealBenchmark.java b/benchmarks/regression/StringToRealBenchmark.java
new file mode 100644
index 0000000..5d04d7b
--- /dev/null
+++ b/benchmarks/regression/StringToRealBenchmark.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+
+public class StringToRealBenchmark {
+
+ @Param({
+ "NaN",
+ "-1",
+ "0",
+ "1",
+ "1.2",
+ "-123.45",
+ "-123.45e8",
+ "-123.45e36"
+ }) String string;
+
+ public void timeFloat_parseFloat(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Float.parseFloat(string);
+ }
+ }
+
+ public void timeDouble_parseDouble(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ Double.parseDouble(string);
+ }
+ }
+}
diff --git a/benchmarks/regression/ThreadLocalBenchmark.java b/benchmarks/regression/ThreadLocalBenchmark.java
new file mode 100644
index 0000000..59f7fc6
--- /dev/null
+++ b/benchmarks/regression/ThreadLocalBenchmark.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+public class ThreadLocalBenchmark {
+ private static final ThreadLocal<char[]> BUFFER = new ThreadLocal<char[]>() {
+ @Override protected char[] initialValue() {
+ return new char[20];
+ }
+ };
+
+ public void timeThreadLocal_get(int reps) {
+ for (int rep = 0; rep < reps; ++rep) {
+ BUFFER.get();
+ }
+ }
+}
diff --git a/benchmarks/regression/TimeZoneBenchmark.java b/benchmarks/regression/TimeZoneBenchmark.java
new file mode 100644
index 0000000..191e00d
--- /dev/null
+++ b/benchmarks/regression/TimeZoneBenchmark.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2010 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import java.util.TimeZone;
+
+public class TimeZoneBenchmark {
+ public void timeTimeZone_getDefault(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getDefault();
+ }
+ }
+
+ public void timeTimeZone_getTimeZoneUTC(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getTimeZone("UTC");
+ }
+ }
+
+ public void timeTimeZone_getTimeZone_default(int reps) throws Exception {
+ String defaultId = TimeZone.getDefault().getID();
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getTimeZone(defaultId);
+ }
+ }
+
+ // A time zone with relatively few transitions.
+ public void timeTimeZone_getTimeZone_America_Caracas(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getTimeZone("America/Caracas");
+ }
+ }
+
+ // A time zone with a lot of transitions.
+ public void timeTimeZone_getTimeZone_America_Santiago(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getTimeZone("America/Santiago");
+ }
+ }
+
+ public void timeTimeZone_getTimeZone_GMT_plus_10(int reps) throws Exception {
+ for (int rep = 0; rep < reps; ++rep) {
+ TimeZone.getTimeZone("GMT+10");
+ }
+ }
+}
diff --git a/benchmarks/regression/URLConnectionBenchmark.java b/benchmarks/regression/URLConnectionBenchmark.java
new file mode 100644
index 0000000..bd7c047
--- /dev/null
+++ b/benchmarks/regression/URLConnectionBenchmark.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.Param;
+import com.google.mockwebserver.Dispatcher;
+import com.google.mockwebserver.MockResponse;
+import com.google.mockwebserver.MockWebServer;
+import com.google.mockwebserver.RecordedRequest;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+public final class URLConnectionBenchmark {
+
+ @Param({"0", "1024", "1048576"}) private int bodySize;
+ @Param({"2048"}) private int chunkSize;
+ @Param({"1024"}) private int readBufferSize;
+ @Param private ResponseHeaders responseHeaders;
+ @Param private TransferEncoding transferEncoding;
+ private byte[] readBuffer;
+
+ private MockWebServer server;
+ private URL url;
+
+ private static class SingleResponseDispatcher extends Dispatcher {
+ private MockResponse response;
+ SingleResponseDispatcher(MockResponse response) {
+ this.response = response;
+ }
+ @Override public MockResponse dispatch(RecordedRequest request) {
+ return response;
+ }
+ };
+
+ protected void setUp() throws Exception {
+ readBuffer = new byte[readBufferSize];
+ server = new MockWebServer();
+
+ MockResponse response = new MockResponse();
+ responseHeaders.apply(response);
+ transferEncoding.setBody(response, bodySize, chunkSize);
+
+ // keep serving the same response for all iterations
+ server.setDispatcher(new SingleResponseDispatcher(response));
+ server.play();
+
+ url = server.getUrl("/");
+ get(); // ensure the server has started its threads, etc.
+ }
+
+ protected void tearDown() throws Exception {
+ server.shutdown();
+ }
+
+ public int timeGet(int reps) throws IOException {
+ int totalBytesRead = 0;
+ for (int i = 0; i < reps; i++) {
+ totalBytesRead += get();
+ }
+ return totalBytesRead;
+ }
+
+ private int get() throws IOException {
+ int totalBytesRead = 0;
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ // URLConnection connection = url.openConnection();
+ InputStream in = connection.getInputStream();
+ int count;
+ while ((count = in.read(readBuffer)) != -1) {
+ totalBytesRead += count;
+ }
+ return totalBytesRead;
+ }
+
+ enum TransferEncoding {
+ FIXED_LENGTH,
+ CHUNKED;
+
+ void setBody(MockResponse response, int bodySize, int chunkSize) throws IOException {
+ if (this == TransferEncoding.FIXED_LENGTH) {
+ response.setBody(new byte[bodySize]);
+ } else if (this == TransferEncoding.CHUNKED) {
+ response.setChunkedBody(new byte[bodySize], chunkSize);
+ }
+ }
+ }
+
+ enum ResponseHeaders {
+ MINIMAL,
+ TYPICAL;
+
+ void apply(MockResponse response) {
+ if (this == TYPICAL) {
+ /* from http://api.twitter.com/1/statuses/public_timeline.json */
+ response.addHeader("Date: Wed, 30 Jun 2010 17:57:39 GMT");
+ response.addHeader("Server: hi");
+ response.addHeader("X-RateLimit-Remaining: 0");
+ response.addHeader("X-Runtime: 0.01637");
+ response.addHeader("Content-Type: application/json; charset=utf-8");
+ response.addHeader("X-RateLimit-Class: api_whitelisted");
+ response.addHeader("Cache-Control: no-cache, max-age=300");
+ response.addHeader("X-RateLimit-Reset: 1277920980");
+ response.addHeader("Set-Cookie: _twitter_sess=BAh7EDoOcmV0dXJuX3RvIjZodHRwOi8vZGV2L"
+ + "nR3aXR0ZXIuY29tL3BhZ2Vz%250AL3NpZ25faW5fd2l0aF90d2l0dGVyOgxjc3JmX2lkIiUw"
+ + "ODFhNGY2NTM5NjRm%250ANjY1N2M2NzcwNWI0MDlmZGZjZjoVaW5fbmV3X3VzZXJfZmxvdzA"
+ + "6EXRyYW5z%250AX3Byb21wdDAiKXNob3dfZGlzY292ZXJhYmlsaXR5X2Zvcl9qZXNzZXdpbH"
+ + "Nv%250AbjA6E3Nob3dfaGVscF9saW5rMDoTcGFzc3dvcmRfdG9rZW4iLWUyYjlhNmM3%250A"
+ + "MWJiNzI3NWNlZDI1NDY3MGMzZWNmMTE0MjI4N2EyNGE6D2NyZWF0ZWRfYXRs%250AKwhiM%2"
+ + "52F6JKQE6CXVzZXJpA8tE3iIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxl%250Acjo6Rmxhc2"
+ + "g6OkZsYXNoSGFzaHsABjoKQHVzZWR7ADoHaWQiJWZmMTNhM2Qx%250AZTU1YTkzMmYyMWM0M"
+ + "GNhZjU4NDVjMTQz--11250628c85830219438eb7eba96a541a9af4098; domain=.twitt"
+ + "er.com; path=/");
+ response.addHeader("Expires: Wed, 30 Jun 2010 18:02:39 GMT");
+ response.addHeader("Vary: Accept-Encoding");
+ }
+ }
+ }
+}
diff --git a/benchmarks/regression/XmlEntitiesBenchmark.java b/benchmarks/regression/XmlEntitiesBenchmark.java
new file mode 100644
index 0000000..7c50975
--- /dev/null
+++ b/benchmarks/regression/XmlEntitiesBenchmark.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package benchmarks.regression;
+
+import com.google.caliper.BeforeExperiment;
+import com.google.caliper.Param;
+import java.io.StringReader;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.xml.sax.InputSource;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserFactory;
+
+// http://code.google.com/p/android/issues/detail?id=18102
+public final class XmlEntitiesBenchmark {
+
+ @Param({"10", "100", "1000"}) int length;
+ @Param({"0", "0.5", "1.0"}) float entityFraction;
+
+ private XmlPullParserFactory xmlPullParserFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+
+ /** a string like {@code <doc>&amp;&amp;++</doc>}. */
+ private String xml;
+
+ @BeforeExperiment
+ protected void setUp() throws Exception {
+ xmlPullParserFactory = XmlPullParserFactory.newInstance();
+ documentBuilderFactory = DocumentBuilderFactory.newInstance();
+
+ StringBuilder xmlBuilder = new StringBuilder();
+ xmlBuilder.append("<doc>");
+ for (int i = 0; i < (length * entityFraction); i++) {
+ xmlBuilder.append("&amp;");
+ }
+ while (xmlBuilder.length() < length) {
+ xmlBuilder.append("+");
+ }
+ xmlBuilder.append("</doc>");
+ xml = xmlBuilder.toString();
+ }
+
+ public void timeXmlParser(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ XmlPullParser parser = xmlPullParserFactory.newPullParser();
+ parser.setInput(new StringReader(xml));
+ while (parser.next() != XmlPullParser.END_DOCUMENT) {
+ }
+ }
+ }
+
+ public void timeDocumentBuilder(int reps) throws Exception {
+ for (int i = 0; i < reps; i++) {
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ documentBuilder.parse(new InputSource(new StringReader(xml)));
+ }
+ }
+}