Merge "Change parameterization type in libcore benchmarks." am: 11915f3675 am: 121f0b4a9c
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2278282 Change-Id: I5d928983489811f363f519c0a281860c12ec8f9a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -43,6 +43,9 @@ android_test {
|
|||||||
"apct-perftests-resources-manager-apps",
|
"apct-perftests-resources-manager-apps",
|
||||||
"apct-perftests-utils",
|
"apct-perftests-utils",
|
||||||
"collector-device-lib",
|
"collector-device-lib",
|
||||||
|
"compatibility-device-util-axt",
|
||||||
|
"junit",
|
||||||
|
"junit-params",
|
||||||
"core-tests-support",
|
"core-tests-support",
|
||||||
"guava",
|
"guava",
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -20,18 +20,19 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class DeepArrayOpsPerfTest {
|
public class DeepArrayOpsPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -39,19 +40,14 @@ public class DeepArrayOpsPerfTest {
|
|||||||
private Object[] mArray;
|
private Object[] mArray;
|
||||||
private Object[] mArray2;
|
private Object[] mArray2;
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
public static Collection<Object[]> getData() {
|
||||||
public int mArrayLength;
|
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "mArrayLength({0})")
|
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}});
|
return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
public void setUp(int arrayLength) throws Exception {
|
||||||
public void setUp() throws Exception {
|
mArray = new Object[arrayLength * 14];
|
||||||
mArray = new Object[mArrayLength * 14];
|
mArray2 = new Object[arrayLength * 14];
|
||||||
mArray2 = new Object[mArrayLength * 14];
|
for (int i = 0; i < arrayLength; i += 14) {
|
||||||
for (int i = 0; i < mArrayLength; i += 14) {
|
|
||||||
mArray[i] = new IntWrapper(i);
|
mArray[i] = new IntWrapper(i);
|
||||||
mArray2[i] = new IntWrapper(i);
|
mArray2[i] = new IntWrapper(i);
|
||||||
|
|
||||||
@@ -99,7 +95,9 @@ public class DeepArrayOpsPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deepHashCode() {
|
@Parameters(method = "getData")
|
||||||
|
public void deepHashCode(int arrayLength) throws Exception {
|
||||||
|
setUp(arrayLength);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Arrays.deepHashCode(mArray);
|
Arrays.deepHashCode(mArray);
|
||||||
@@ -107,7 +105,9 @@ public class DeepArrayOpsPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void deepEquals() {
|
@Parameters(method = "getData")
|
||||||
|
public void deepEquals(int arrayLength) throws Exception {
|
||||||
|
setUp(arrayLength);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Arrays.deepEquals(mArray, mArray2);
|
Arrays.deepEquals(mArray, mArray2);
|
||||||
|
|||||||
@@ -20,22 +20,22 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class SystemArrayCopyPerfTest {
|
public class SystemArrayCopyPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "arrayLength={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096},
|
{2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096},
|
||||||
@@ -43,12 +43,10 @@ public class SystemArrayCopyPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int arrayLength;
|
|
||||||
|
|
||||||
// Provides benchmarking for different types of arrays using the arraycopy function.
|
// Provides benchmarking for different types of arrays using the arraycopy function.
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemCharArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemCharArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
char[] src = new char[len];
|
char[] src = new char[len];
|
||||||
char[] dst = new char[len];
|
char[] dst = new char[len];
|
||||||
@@ -59,7 +57,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemByteArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemByteArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
byte[] src = new byte[len];
|
byte[] src = new byte[len];
|
||||||
byte[] dst = new byte[len];
|
byte[] dst = new byte[len];
|
||||||
@@ -70,7 +69,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemShortArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemShortArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
short[] src = new short[len];
|
short[] src = new short[len];
|
||||||
short[] dst = new short[len];
|
short[] dst = new short[len];
|
||||||
@@ -81,7 +81,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemIntArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemIntArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
int[] src = new int[len];
|
int[] src = new int[len];
|
||||||
int[] dst = new int[len];
|
int[] dst = new int[len];
|
||||||
@@ -92,7 +93,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemLongArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemLongArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
long[] src = new long[len];
|
long[] src = new long[len];
|
||||||
long[] dst = new long[len];
|
long[] dst = new long[len];
|
||||||
@@ -103,7 +105,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemFloatArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemFloatArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
float[] src = new float[len];
|
float[] src = new float[len];
|
||||||
float[] dst = new float[len];
|
float[] dst = new float[len];
|
||||||
@@ -114,7 +117,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemDoubleArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemDoubleArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
double[] src = new double[len];
|
double[] src = new double[len];
|
||||||
double[] dst = new double[len];
|
double[] dst = new double[len];
|
||||||
@@ -125,7 +129,8 @@ public class SystemArrayCopyPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSystemBooleanArrayCopy() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSystemBooleanArrayCopy(int arrayLength) {
|
||||||
final int len = arrayLength;
|
final int len = arrayLength;
|
||||||
boolean[] src = new boolean[len];
|
boolean[] src = new boolean[len];
|
||||||
boolean[] dst = new boolean[len];
|
boolean[] dst = new boolean[len];
|
||||||
|
|||||||
@@ -20,42 +20,32 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
import org.xmlpull.v1.XmlSerializer;
|
import org.xmlpull.v1.XmlSerializer;
|
||||||
|
|
||||||
import java.io.CharArrayWriter;
|
import java.io.CharArrayWriter;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class XmlSerializePerfTest {
|
public class XmlSerializePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mDatasetAsString({0}), mSeed({1})")
|
private Object[] getParams() {
|
||||||
public static Collection<Object[]> data() {
|
return new Object[][] {
|
||||||
return Arrays.asList(
|
new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 854328},
|
||||||
new Object[][] {
|
new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 854328},
|
||||||
{"0.99 0.7 0.7 0.7 0.7 0.7", 854328},
|
new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 312547},
|
||||||
{"0.999 0.3 0.3 0.95 0.9 0.9", 854328},
|
new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 312547}
|
||||||
{"0.99 0.7 0.7 0.7 0.7 0.7", 312547},
|
};
|
||||||
{"0.999 0.3 0.3 0.95 0.9 0.9", 312547}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public String mDatasetAsString;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public int mSeed;
|
|
||||||
|
|
||||||
double[] mDataset;
|
double[] mDataset;
|
||||||
private Constructor<? extends XmlSerializer> mKxmlConstructor;
|
private Constructor<? extends XmlSerializer> mKxmlConstructor;
|
||||||
private Constructor<? extends XmlSerializer> mFastConstructor;
|
private Constructor<? extends XmlSerializer> mFastConstructor;
|
||||||
@@ -100,8 +90,7 @@ public class XmlSerializePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Before
|
public void setUp(String datasetAsString) throws Exception {
|
||||||
public void setUp() throws Exception {
|
|
||||||
mKxmlConstructor =
|
mKxmlConstructor =
|
||||||
(Constructor)
|
(Constructor)
|
||||||
Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor();
|
Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor();
|
||||||
@@ -109,28 +98,32 @@ public class XmlSerializePerfTest {
|
|||||||
(Constructor)
|
(Constructor)
|
||||||
Class.forName("com.android.internal.util.FastXmlSerializer")
|
Class.forName("com.android.internal.util.FastXmlSerializer")
|
||||||
.getConstructor();
|
.getConstructor();
|
||||||
String[] splitStrings = mDatasetAsString.split(" ");
|
String[] splitStrings = datasetAsString.split(" ");
|
||||||
mDataset = new double[splitStrings.length];
|
mDataset = new double[splitStrings.length];
|
||||||
for (int i = 0; i < splitStrings.length; i++) {
|
for (int i = 0; i < splitStrings.length; i++) {
|
||||||
mDataset[i] = Double.parseDouble(splitStrings[i]);
|
mDataset[i] = Double.parseDouble(splitStrings[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor)
|
private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor, int seed)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
serializeRandomXml(ctor, mSeed);
|
serializeRandomXml(ctor, seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeKxml() throws Exception {
|
@Parameters(method = "getParams")
|
||||||
internalTimeSerializer(mKxmlConstructor);
|
public void timeKxml(String datasetAsString, int seed) throws Exception {
|
||||||
|
setUp(datasetAsString);
|
||||||
|
internalTimeSerializer(mKxmlConstructor, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeFast() throws Exception {
|
@Parameters(method = "getParams")
|
||||||
internalTimeSerializer(mFastConstructor);
|
public void timeFast(String datasetAsString, int seed) throws Exception {
|
||||||
|
setUp(datasetAsString);
|
||||||
|
internalTimeSerializer(mFastConstructor, seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -38,23 +38,18 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class ZipFilePerfTest {
|
public class ZipFilePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
private File mFile;
|
private File mFile;
|
||||||
|
|
||||||
@Parameters(name = "numEntries={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{128}, {1024}, {8192}});
|
return Arrays.asList(new Object[][] {{128}, {1024}, {8192}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
public void setUp(int numEntries) throws Exception {
|
||||||
public int numEntries;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
mFile = File.createTempFile(getClass().getName(), ".zip");
|
mFile = File.createTempFile(getClass().getName(), ".zip");
|
||||||
mFile.deleteOnExit();
|
mFile.deleteOnExit();
|
||||||
writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0);
|
writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0);
|
||||||
@@ -66,7 +61,9 @@ public class ZipFilePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeZipFileOpen() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeZipFileOpen(int numEntries) throws Exception {
|
||||||
|
setUp(numEntries);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
ZipFile zf = new ZipFile(mFile);
|
ZipFile zf = new ZipFile(mFile);
|
||||||
|
|||||||
@@ -20,12 +20,13 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -39,21 +40,17 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class ZipFileReadPerfTest {
|
public class ZipFileReadPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "readBufferSize={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{1024}, {16384}, {65536}});
|
return Arrays.asList(new Object[][] {{1024}, {16384}, {65536}});
|
||||||
}
|
}
|
||||||
|
|
||||||
private File mFile;
|
private File mFile;
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int readBufferSize;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
mFile = File.createTempFile(getClass().getName(), ".zip");
|
mFile = File.createTempFile(getClass().getName(), ".zip");
|
||||||
@@ -90,7 +87,8 @@ public class ZipFileReadPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeZipFileRead() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeZipFileRead(int readBufferSize) throws Exception {
|
||||||
byte[] readBuffer = new byte[readBufferSize];
|
byte[] readBuffer = new byte[readBufferSize];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
|
|||||||
@@ -20,96 +20,99 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class BitSetPerfTest {
|
public class BitSetPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mSize={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{1000}, {10000}});
|
return Arrays.asList(new Object[][] {{1000}, {10000}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int mSize;
|
|
||||||
|
|
||||||
private BitSet mBitSet;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
mBitSet = new BitSet(mSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsEmptyTrue() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsEmptyTrue(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
if (!mBitSet.isEmpty()) throw new RuntimeException();
|
if (!bitSet.isEmpty()) throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsEmptyFalse() {
|
@Parameters(method = "getData")
|
||||||
mBitSet.set(mBitSet.size() - 1);
|
public void timeIsEmptyFalse(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
|
bitSet.set(bitSet.size() - 1);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
if (mBitSet.isEmpty()) throw new RuntimeException();
|
if (bitSet.isEmpty()) throw new RuntimeException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGet() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGet(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mBitSet.get(++i % mSize);
|
bitSet.get(++i % size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeClear() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeClear(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mBitSet.clear(++i % mSize);
|
bitSet.clear(++i % size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSet() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSet(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mBitSet.set(++i % mSize);
|
bitSet.set(++i % size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSetOn() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSetOn(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mBitSet.set(++i % mSize, true);
|
bitSet.set(++i % size, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSetOff() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSetOff(int size) {
|
||||||
|
BitSet bitSet = new BitSet(size);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mBitSet.set(++i % mSize, false);
|
bitSet.set(++i % size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,18 +20,19 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.text.BreakIterator;
|
import java.text.BreakIterator;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public final class BreakIteratorPerfTest {
|
public final class BreakIteratorPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -41,36 +42,37 @@ public final class BreakIteratorPerfTest {
|
|||||||
Locale.US,
|
Locale.US,
|
||||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mollis consequat"
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi mollis consequat"
|
||||||
+ " nisl non pharetra. Praesent pretium vehicula odio sed ultrices. Aenean a"
|
+ " nisl non pharetra. Praesent pretium vehicula odio sed ultrices. Aenean a"
|
||||||
+ " felis libero. Vivamus sed commodo nibh. Pellentesque turpis lectus, euismod"
|
+ " felis libero. Vivamus sed commodo nibh. Pellentesque turpis lectus,"
|
||||||
+ " vel ante nec, cursus posuere orci. Suspendisse velit neque, fermentum"
|
+ " euismod vel ante nec, cursus posuere orci. Suspendisse velit neque,"
|
||||||
+ " luctus ultrices in, ultrices vitae arcu. Duis tincidunt cursus lorem. Nam"
|
+ " fermentum luctus ultrices in, ultrices vitae arcu. Duis tincidunt cursus"
|
||||||
+ " ultricies accumsan quam vitae imperdiet. Pellentesque habitant morbi"
|
+ " lorem. Nam ultricies accumsan quam vitae imperdiet. Pellentesque habitant"
|
||||||
+ " tristique senectus et netus et malesuada fames ac turpis egestas. Quisque"
|
+ " morbi tristique senectus et netus et malesuada fames ac turpis egestas."
|
||||||
+ " aliquet pretium nisi, eget laoreet enim molestie sit amet. Class aptent"
|
+ " Quisque aliquet pretium nisi, eget laoreet enim molestie sit amet. Class"
|
||||||
+ " taciti sociosqu ad litora torquent per conubia nostra, per inceptos"
|
+ " aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos"
|
||||||
+ " himenaeos.\n"
|
+ " himenaeos.\n"
|
||||||
+ "Nam dapibus aliquam lacus ac suscipit. Proin in nibh sit amet purus congue"
|
+ "Nam dapibus aliquam lacus ac suscipit. Proin in nibh sit amet purus congue"
|
||||||
+ " laoreet eget quis nisl. Morbi gravida dignissim justo, a venenatis ante"
|
+ " laoreet eget quis nisl. Morbi gravida dignissim justo, a venenatis ante"
|
||||||
+ " pulvinar at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin"
|
+ " pulvinar at. Lorem ipsum dolor sit amet, consectetur adipiscing elit."
|
||||||
+ " ultrices vestibulum dui, vel aliquam lacus aliquam quis. Duis fringilla"
|
+ " Proin ultrices vestibulum dui, vel aliquam lacus aliquam quis. Duis"
|
||||||
+ " sapien ac lacus egestas, vel adipiscing elit euismod. Donec non tellus"
|
+ " fringilla sapien ac lacus egestas, vel adipiscing elit euismod. Donec non"
|
||||||
+ " odio. Donec gravida eu massa ac feugiat. Aliquam erat volutpat. Praesent id"
|
+ " tellus odio. Donec gravida eu massa ac feugiat. Aliquam erat volutpat."
|
||||||
+ " adipiscing metus, nec laoreet enim. Aliquam vitae posuere turpis. Mauris ac"
|
+ " Praesent id adipiscing metus, nec laoreet enim. Aliquam vitae posuere"
|
||||||
+ " pharetra sem. In at placerat tortor. Vivamus ac vehicula neque. Cras"
|
+ " turpis. Mauris ac pharetra sem. In at placerat tortor. Vivamus ac vehicula"
|
||||||
+ " volutpat ullamcorper massa et varius. Praesent sagittis neque vitae nulla"
|
+ " neque. Cras volutpat ullamcorper massa et varius. Praesent sagittis neque"
|
||||||
+ " euismod pharetra.\n"
|
+ " vitae nulla euismod pharetra.\n"
|
||||||
+ "Sed placerat sapien non molestie sollicitudin. Nullam sit amet dictum quam."
|
+ "Sed placerat sapien non molestie sollicitudin. Nullam sit amet dictum quam."
|
||||||
+ " Etiam tincidunt tortor vel pretium vehicula. Praesent fringilla ipsum vel"
|
+ " Etiam tincidunt tortor vel pretium vehicula. Praesent fringilla ipsum vel"
|
||||||
+ " velit luctus dignissim. Nulla massa ligula, mattis in enim et, mattis"
|
+ " velit luctus dignissim. Nulla massa ligula, mattis in enim et, mattis"
|
||||||
+ " lacinia odio. Suspendisse tristique urna a orci commodo tempor. Duis"
|
+ " lacinia odio. Suspendisse tristique urna a orci commodo tempor. Duis"
|
||||||
+ " lacinia egestas arcu a sollicitudin.\n"
|
+ " lacinia egestas arcu a sollicitudin.\n"
|
||||||
+ "In ac feugiat lacus. Nunc fermentum eu est at tristique. Pellentesque quis"
|
+ "In ac feugiat lacus. Nunc fermentum eu est at tristique. Pellentesque quis"
|
||||||
+ " ligula et orci placerat lacinia. Maecenas quis mauris diam. Etiam mi ipsum,"
|
+ " ligula et orci placerat lacinia. Maecenas quis mauris diam. Etiam mi"
|
||||||
+ " tempus in purus quis, euismod faucibus orci. Nulla facilisi. Praesent sit"
|
+ " ipsum, tempus in purus quis, euismod faucibus orci. Nulla facilisi."
|
||||||
+ " amet sapien vel elit porta adipiscing. Phasellus sit amet volutpat diam.\n"
|
+ " Praesent sit amet sapien vel elit porta adipiscing. Phasellus sit amet"
|
||||||
+ "Proin bibendum elit non lacus pharetra, quis eleifend tellus placerat. Nulla"
|
+ " volutpat diam.\n"
|
||||||
+ " facilisi. Maecenas ante diam, pellentesque mattis mattis in, porta ut"
|
+ "Proin bibendum elit non lacus pharetra, quis eleifend tellus placerat."
|
||||||
+ " lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices"
|
+ " 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"
|
+ " posuere cubilia Curae; Nunc interdum tristique metus, in scelerisque odio"
|
||||||
+ " fermentum eget. Cras nec venenatis lacus. Aenean euismod eget metus quis"
|
+ " fermentum eget. Cras nec venenatis lacus. Aenean euismod eget metus quis"
|
||||||
+ " molestie. Cras tincidunt dolor ut massa ornare, in elementum lacus auctor."
|
+ " molestie. Cras tincidunt dolor ut massa ornare, in elementum lacus auctor."
|
||||||
@@ -80,29 +82,29 @@ public final class BreakIteratorPerfTest {
|
|||||||
LONGPARA(
|
LONGPARA(
|
||||||
Locale.US,
|
Locale.US,
|
||||||
"During dinner, Mr. Bennet scarcely spoke at all; but when the servants were"
|
"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"
|
+ " withdrawn, he thought it time to have some conversation with his guest,"
|
||||||
+ " therefore started a subject in which he expected him to shine, by observing"
|
+ " and therefore started a subject in which he expected him to shine, by"
|
||||||
+ " that he seemed very fortunate in his patroness. Lady Catherine de Bourgh's"
|
+ " observing that he seemed very fortunate in his patroness. Lady Catherine"
|
||||||
+ " attention to his wishes, and consideration for his comfort, appeared very"
|
+ " de Bourgh's attention to his wishes, and consideration for his comfort,"
|
||||||
+ " remarkable. Mr. Bennet could not have chosen better. Mr. Collins was"
|
+ " appeared very remarkable. Mr. Bennet could not have chosen better. Mr."
|
||||||
+ " eloquent in her praise. The subject elevated him to more than usual"
|
+ " Collins was eloquent in her praise. The subject elevated him to more than"
|
||||||
+ " solemnity of manner, and with a most important aspect he protested that"
|
+ " usual solemnity of manner, and with a most important aspect he protested"
|
||||||
+ " \"he had never in his life witnessed such behaviour in a person of"
|
+ " 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"
|
+ " rank--such affability and condescension, as he had himself experienced"
|
||||||
+ " Lady Catherine. She had been graciously pleased to approve of both of the"
|
+ " from Lady Catherine. She had been graciously pleased to approve of both of"
|
||||||
+ " discourses which he had already had the honour of preaching before her. She"
|
+ " the discourses which he had already had the honour of preaching before"
|
||||||
+ " had also asked him twice to dine at Rosings, and had sent for him only the"
|
+ " her. She had also asked him twice to dine at Rosings, and had sent for him"
|
||||||
+ " Saturday before, to make up her pool of quadrille in the evening. Lady"
|
+ " only the Saturday before, to make up her pool of quadrille in the evening."
|
||||||
+ " Catherine was reckoned proud by many people he knew, but _he_ had never"
|
+ " Lady Catherine was reckoned proud by many people he knew, but _he_ had"
|
||||||
+ " seen anything but affability in her. She had always spoken to him as she"
|
+ " never seen anything but affability in her. She had always spoken to him as"
|
||||||
+ " would to any other gentleman; she made not the smallest objection to his"
|
+ " she would to any other gentleman; she made not the smallest objection to"
|
||||||
+ " joining in the society of the neighbourhood nor to his leaving the parish"
|
+ " his joining in the society of the neighbourhood nor to his leaving the"
|
||||||
+ " occasionally for a week or two, to visit his relations. She had even"
|
+ " parish occasionally for a week or two, to visit his relations. She had"
|
||||||
+ " condescended to advise him to marry as soon as he could, provided he chose"
|
+ " even condescended to advise him to marry as soon as he could, provided he"
|
||||||
+ " with discretion; and had once paid him a visit in his humble parsonage,"
|
+ " chose with discretion; and had once paid him a visit in his humble"
|
||||||
+ " where she had perfectly approved all the alterations he had been making,"
|
+ " parsonage, where she had perfectly approved all the alterations he had"
|
||||||
+ " and had even vouchsafed to suggest some herself--some shelves in the closet"
|
+ " been making, and had even vouchsafed to suggest some herself--some shelves"
|
||||||
+ " up stairs.\""),
|
+ " in the closet up stairs.\""),
|
||||||
GERMAN(
|
GERMAN(
|
||||||
Locale.GERMANY,
|
Locale.GERMANY,
|
||||||
"Aber dieser Freiheit setzte endlich der Winter ein Ziel. Draußen auf den Feldern"
|
"Aber dieser Freiheit setzte endlich der Winter ein Ziel. Draußen auf den Feldern"
|
||||||
@@ -119,15 +121,14 @@ public final class BreakIteratorPerfTest {
|
|||||||
+ " เดิมทีเป็นการผสมผสานกันระหว่างสำเนียงอยุธยาและชาวไทยเชื้อสายจีนรุ่นหลังที่"
|
+ " เดิมทีเป็นการผสมผสานกันระหว่างสำเนียงอยุธยาและชาวไทยเชื้อสายจีนรุ่นหลังที่"
|
||||||
+ "พูดไทยแทนกลุ่มภาษาจีน"
|
+ "พูดไทยแทนกลุ่มภาษาจีน"
|
||||||
+ " ลักษณะเด่นคือมีการออกเสียงที่ชัดเจนและแข็งกระด้างซึ่งได้รับอิทธิพลจากภาษาแต"
|
+ " ลักษณะเด่นคือมีการออกเสียงที่ชัดเจนและแข็งกระด้างซึ่งได้รับอิทธิพลจากภาษาแต"
|
||||||
+ "้จิ๋ว"
|
+ "้จิ๋ว การออกเสียงพยัญชนะ สระ การผันวรรณยุกต์ที่ในภาษาไทยมาตรฐาน"
|
||||||
+ " การออกเสียงพยัญชนะ สระ การผันวรรณยุกต์ที่ในภาษาไทยมาตรฐาน"
|
|
||||||
+ " มาจากสำเนียงถิ่นนี้ในขณะที่ภาษาไทยสำเนียงอื่นล้วนเหน่อทั้งสิ้น"
|
+ " มาจากสำเนียงถิ่นนี้ในขณะที่ภาษาไทยสำเนียงอื่นล้วนเหน่อทั้งสิ้น"
|
||||||
+ " คำศัพท์ที่ใช้ในสำเนียงกรุงเทพจำนวนมากได้รับมาจากกลุ่มภาษาจีนเช่นคำว่า โป๊,"
|
+ " คำศัพท์ที่ใช้ในสำเนียงกรุงเทพจำนวนมากได้รับมาจากกลุ่มภาษาจีนเช่นคำว่า โป๊,"
|
||||||
+ " เฮ็ง, อาหมวย, อาซิ่ม ซึ่งมาจากภาษาแต้จิ๋ว และจากภาษาจีนเช่น ถู(涂), ชิ่ว(去"
|
+ " เฮ็ง, อาหมวย, อาซิ่ม ซึ่งมาจากภาษาแต้จิ๋ว และจากภาษาจีนเช่น ถู(涂), ชิ่ว(去"
|
||||||
+ " อ่านว่า\"ชู่\") และคำว่า ทาย(猜 อ่านว่า \"ชาย\") เป็นต้น"
|
+ " อ่านว่า\"ชู่\") และคำว่า ทาย(猜 อ่านว่า \"ชาย\") เป็นต้น"
|
||||||
+ " เนื่องจากสำเนียงกรุงเทพได้รับอิทธิพลมาจากภาษาจีนดังนั้นตัวอักษร \"ร\""
|
+ " เนื่องจากสำเนียงกรุงเทพได้รับอิทธิพลมาจากภาษาจีนดังนั้นตัวอักษร \"ร\""
|
||||||
+ " มักออกเสียงเหมารวมเป็น \"ล\" หรือคำควบกล่ำบางคำถูกละทิ้งไปด้วยเช่น รู้ เป็น"
|
+ " มักออกเสียงเหมารวมเป็น \"ล\" หรือคำควบกล่ำบางคำถูกละทิ้งไปด้วยเช่น รู้"
|
||||||
+ " ลู้, เรื่อง เป็น เลื่อง หรือ ประเทศ เป็น ปะเทศ"
|
+ " เป็น ลู้, เรื่อง เป็น เลื่อง หรือ ประเทศ เป็น ปะเทศ"
|
||||||
+ " เป็นต้นสร้างความลำบากให้แก่ต่างชาติที่ต้องการเรียนภาษาไทย"
|
+ " เป็นต้นสร้างความลำบากให้แก่ต่างชาติที่ต้องการเรียนภาษาไทย"
|
||||||
+ " แต่อย่างไรก็ตามผู้ที่พูดสำเนียงถิ่นนี้ก็สามารถออกอักขระภาษาไทยตามมาตรฐานได"
|
+ " แต่อย่างไรก็ตามผู้ที่พูดสำเนียงถิ่นนี้ก็สามารถออกอักขระภาษาไทยตามมาตรฐานได"
|
||||||
+ "้อย่างถูกต้องเพียงแต่มักเผลอไม่ค่อยออกเสียง"),
|
+ "้อย่างถูกต้องเพียงแต่มักเผลอไม่ค่อยออกเสียง"),
|
||||||
@@ -151,8 +152,7 @@ public final class BreakIteratorPerfTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mText={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{Text.ACCENT}, {Text.BIDI}, {Text.EMOJI}, {Text.EMPTY}, {Text.GERMAN},
|
{Text.ACCENT}, {Text.BIDI}, {Text.EMOJI}, {Text.EMPTY}, {Text.GERMAN},
|
||||||
@@ -161,15 +161,13 @@ public final class BreakIteratorPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Text mText;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeBreakIterator() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeBreakIterator(Text text) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
BreakIterator it = BreakIterator.getLineInstance(mText.mLocale);
|
BreakIterator it = BreakIterator.getLineInstance(text.mLocale);
|
||||||
it.setText(mText.mText);
|
it.setText(text.mText);
|
||||||
|
|
||||||
while (it.next() != BreakIterator.DONE) {
|
while (it.next() != BreakIterator.DONE) {
|
||||||
// Keep iterating
|
// Keep iterating
|
||||||
@@ -178,12 +176,13 @@ public final class BreakIteratorPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIcuBreakIterator() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIcuBreakIterator(Text text) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
android.icu.text.BreakIterator it =
|
android.icu.text.BreakIterator it =
|
||||||
android.icu.text.BreakIterator.getLineInstance(mText.mLocale);
|
android.icu.text.BreakIterator.getLineInstance(text.mLocale);
|
||||||
it.setText(mText.mText);
|
it.setText(text.mText);
|
||||||
|
|
||||||
while (it.next() != android.icu.text.BreakIterator.DONE) {
|
while (it.next() != android.icu.text.BreakIterator.DONE) {
|
||||||
// Keep iterating
|
// Keep iterating
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,13 +35,12 @@ import java.nio.channels.FileChannel;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class BulkPerfTest {
|
public class BulkPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mAlign({0}), mSBuf({1}), mDBuf({2}), mSize({3})")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{true, MyBufferType.DIRECT, MyBufferType.DIRECT, 4096},
|
{true, MyBufferType.DIRECT, MyBufferType.DIRECT, 4096},
|
||||||
@@ -82,24 +82,12 @@ public class BulkPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public boolean mAlign;
|
|
||||||
|
|
||||||
enum MyBufferType {
|
enum MyBufferType {
|
||||||
DIRECT,
|
DIRECT,
|
||||||
HEAP,
|
HEAP,
|
||||||
MAPPED
|
MAPPED
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public MyBufferType mSBuf;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(2)
|
|
||||||
public MyBufferType mDBuf;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(3)
|
|
||||||
public int mSize;
|
|
||||||
|
|
||||||
public static ByteBuffer newBuffer(boolean aligned, MyBufferType bufferType, int bsize)
|
public static ByteBuffer newBuffer(boolean aligned, MyBufferType bufferType, int bsize)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int size = aligned ? bsize : bsize + 8 + 1;
|
int size = aligned ? bsize : bsize + 8 + 1;
|
||||||
@@ -126,13 +114,15 @@ public class BulkPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timePut() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = BulkPerfTest.newBuffer(mAlign, mSBuf, mSize);
|
public void timePut(boolean align, MyBufferType sBuf, MyBufferType dBuf, int size)
|
||||||
ByteBuffer data = BulkPerfTest.newBuffer(mAlign, mDBuf, mSize);
|
throws Exception {
|
||||||
|
ByteBuffer src = BulkPerfTest.newBuffer(align, sBuf, size);
|
||||||
|
ByteBuffer data = BulkPerfTest.newBuffer(align, dBuf, size);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAlign ? 0 : 1);
|
src.position(align ? 0 : 1);
|
||||||
data.position(mAlign ? 0 : 1);
|
data.position(align ? 0 : 1);
|
||||||
src.put(data);
|
src.put(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -41,7 +42,7 @@ import java.nio.channels.FileChannel;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class ByteBufferPerfTest {
|
public class ByteBufferPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -49,15 +50,14 @@ public class ByteBufferPerfTest {
|
|||||||
public enum MyByteOrder {
|
public enum MyByteOrder {
|
||||||
BIG(ByteOrder.BIG_ENDIAN),
|
BIG(ByteOrder.BIG_ENDIAN),
|
||||||
LITTLE(ByteOrder.LITTLE_ENDIAN);
|
LITTLE(ByteOrder.LITTLE_ENDIAN);
|
||||||
final ByteOrder mByteOrder;
|
final ByteOrder byteOrder;
|
||||||
|
|
||||||
MyByteOrder(ByteOrder mByteOrder) {
|
MyByteOrder(ByteOrder byteOrder) {
|
||||||
this.mByteOrder = mByteOrder;
|
this.byteOrder = byteOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mByteOrder={0}, mAligned={1}, mBufferType={2}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{MyByteOrder.BIG, true, MyBufferType.DIRECT},
|
{MyByteOrder.BIG, true, MyBufferType.DIRECT},
|
||||||
@@ -75,21 +75,12 @@ public class ByteBufferPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public MyByteOrder mByteOrder;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public boolean mAligned;
|
|
||||||
|
|
||||||
enum MyBufferType {
|
enum MyBufferType {
|
||||||
DIRECT,
|
DIRECT,
|
||||||
HEAP,
|
HEAP,
|
||||||
MAPPED;
|
MAPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(2)
|
|
||||||
public MyBufferType mBufferType;
|
|
||||||
|
|
||||||
public static ByteBuffer newBuffer(
|
public static ByteBuffer newBuffer(
|
||||||
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws IOException {
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws IOException {
|
||||||
int size = aligned ? 8192 : 8192 + 8 + 1;
|
int size = aligned ? 8192 : 8192 + 8 + 1;
|
||||||
@@ -115,7 +106,7 @@ public class ByteBufferPerfTest {
|
|||||||
result = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
|
result = fc.map(FileChannel.MapMode.READ_WRITE, 0, fc.size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
result.order(byteOrder.mByteOrder);
|
result.order(byteOrder.byteOrder);
|
||||||
result.position(aligned ? 0 : 1);
|
result.position(aligned ? 0 : 1);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -125,11 +116,13 @@ public class ByteBufferPerfTest {
|
|||||||
//
|
//
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getByte() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getByte(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.get();
|
src.get();
|
||||||
}
|
}
|
||||||
@@ -137,24 +130,28 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getByteArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getByteArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
byte[] dst = new byte[1024];
|
byte[] dst = new byte[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
src.get(dst);
|
src.get(dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getByte_indexed() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getByte_indexed(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.get(i);
|
src.get(i);
|
||||||
}
|
}
|
||||||
@@ -162,11 +159,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getChar() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getChar(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getChar();
|
src.getChar();
|
||||||
}
|
}
|
||||||
@@ -174,9 +173,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeCharBuffer_getCharArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeCharBuffer_getCharArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
CharBuffer src =
|
CharBuffer src =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asCharBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asCharBuffer();
|
||||||
char[] dst = new char[1024];
|
char[] dst = new char[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -188,11 +189,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getChar_indexed() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getChar_indexed(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getChar(i * 2);
|
src.getChar(i * 2);
|
||||||
}
|
}
|
||||||
@@ -200,11 +203,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getDouble() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getDouble(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getDouble();
|
src.getDouble();
|
||||||
}
|
}
|
||||||
@@ -212,9 +217,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDoubleBuffer_getDoubleArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeDoubleBuffer_getDoubleArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
DoubleBuffer src =
|
DoubleBuffer src =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asDoubleBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer();
|
||||||
double[] dst = new double[1024];
|
double[] dst = new double[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -226,11 +233,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getFloat() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getFloat(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getFloat();
|
src.getFloat();
|
||||||
}
|
}
|
||||||
@@ -238,9 +247,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeFloatBuffer_getFloatArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeFloatBuffer_getFloatArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
FloatBuffer src =
|
FloatBuffer src =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asFloatBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer();
|
||||||
float[] dst = new float[1024];
|
float[] dst = new float[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -252,11 +263,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getInt() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getInt(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getInt();
|
src.getInt();
|
||||||
}
|
}
|
||||||
@@ -264,9 +277,10 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIntBuffer_getIntArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
IntBuffer src =
|
public void timeIntBuffer_getIntArray(
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asIntBuffer();
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
IntBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asIntBuffer();
|
||||||
int[] dst = new int[1024];
|
int[] dst = new int[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -278,11 +292,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getLong() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getLong(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getLong();
|
src.getLong();
|
||||||
}
|
}
|
||||||
@@ -290,9 +306,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeLongBuffer_getLongArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeLongBuffer_getLongArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
LongBuffer src =
|
LongBuffer src =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asLongBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asLongBuffer();
|
||||||
long[] dst = new long[1024];
|
long[] dst = new long[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -304,11 +322,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_getShort() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_getShort(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.getShort();
|
src.getShort();
|
||||||
}
|
}
|
||||||
@@ -316,9 +336,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeShortBuffer_getShortArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeShortBuffer_getShortArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
ShortBuffer src =
|
ShortBuffer src =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asShortBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asShortBuffer();
|
||||||
short[] dst = new short[1024];
|
short[] dst = new short[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -334,8 +356,10 @@ public class ByteBufferPerfTest {
|
|||||||
//
|
//
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putByte() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putByte(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(0);
|
src.position(0);
|
||||||
@@ -346,24 +370,28 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putByteArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer dst = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putByteArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
byte[] src = new byte[1024];
|
byte[] src = new byte[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
dst.position(mAligned ? 0 : 1);
|
dst.position(aligned ? 0 : 1);
|
||||||
dst.put(src);
|
dst.put(src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putChar() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putChar(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putChar(' ');
|
src.putChar(' ');
|
||||||
}
|
}
|
||||||
@@ -371,9 +399,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeCharBuffer_putCharArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeCharBuffer_putCharArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
CharBuffer dst =
|
CharBuffer dst =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asCharBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asCharBuffer();
|
||||||
char[] src = new char[1024];
|
char[] src = new char[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -385,11 +415,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putDouble() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putDouble(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putDouble(0.0);
|
src.putDouble(0.0);
|
||||||
}
|
}
|
||||||
@@ -397,9 +429,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDoubleBuffer_putDoubleArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeDoubleBuffer_putDoubleArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
DoubleBuffer dst =
|
DoubleBuffer dst =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asDoubleBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asDoubleBuffer();
|
||||||
double[] src = new double[1024];
|
double[] src = new double[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -411,11 +445,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putFloat() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putFloat(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putFloat(0.0f);
|
src.putFloat(0.0f);
|
||||||
}
|
}
|
||||||
@@ -423,9 +459,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeFloatBuffer_putFloatArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeFloatBuffer_putFloatArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
FloatBuffer dst =
|
FloatBuffer dst =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asFloatBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asFloatBuffer();
|
||||||
float[] src = new float[1024];
|
float[] src = new float[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -437,11 +475,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putInt() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putInt(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putInt(0);
|
src.putInt(0);
|
||||||
}
|
}
|
||||||
@@ -449,9 +489,10 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIntBuffer_putIntArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
IntBuffer dst =
|
public void timeIntBuffer_putIntArray(
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asIntBuffer();
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
IntBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asIntBuffer();
|
||||||
int[] src = new int[1024];
|
int[] src = new int[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -463,11 +504,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putLong() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putLong(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putLong(0L);
|
src.putLong(0L);
|
||||||
}
|
}
|
||||||
@@ -475,9 +518,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeLongBuffer_putLongArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeLongBuffer_putLongArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
LongBuffer dst =
|
LongBuffer dst =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asLongBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asLongBuffer();
|
||||||
long[] src = new long[1024];
|
long[] src = new long[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -489,11 +534,13 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBuffer_putShort() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeByteBuffer_putShort(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
for (int i = 0; i < 1024; ++i) {
|
for (int i = 0; i < 1024; ++i) {
|
||||||
src.putShort((short) 0);
|
src.putShort((short) 0);
|
||||||
}
|
}
|
||||||
@@ -501,9 +548,11 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeShortBuffer_putShortArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeShortBuffer_putShortArray(
|
||||||
|
MyByteOrder byteOrder, boolean aligned, MyBufferType bufferType) throws Exception {
|
||||||
ShortBuffer dst =
|
ShortBuffer dst =
|
||||||
ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType).asShortBuffer();
|
ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType).asShortBuffer();
|
||||||
short[] src = new short[1024];
|
short[] src = new short[1024];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -515,6 +564,7 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Parameters(method = "getData")
|
||||||
public void time_new_byteArray() throws Exception {
|
public void time_new_byteArray() throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -523,6 +573,7 @@ public class ByteBufferPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Parameters(method = "getData")
|
||||||
public void time_ByteBuffer_allocate() throws Exception {
|
public void time_ByteBuffer_allocate() throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
|
|||||||
@@ -20,23 +20,23 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class ByteBufferScalarVersusVectorPerfTest {
|
public class ByteBufferScalarVersusVectorPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mByteOrder={0}, mAligned={1}, mBufferType={2}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{
|
{
|
||||||
@@ -102,19 +102,15 @@ public class ByteBufferScalarVersusVectorPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public ByteBufferPerfTest.MyByteOrder mByteOrder;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public boolean mAligned;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(2)
|
|
||||||
public ByteBufferPerfTest.MyBufferType mBufferType;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeManualByteBufferCopy() throws Exception {
|
@Parameters(method = "getData")
|
||||||
ByteBuffer src = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
public void timeManualByteBufferCopy(
|
||||||
ByteBuffer dst = ByteBufferPerfTest.newBuffer(mByteOrder, mAligned, mBufferType);
|
ByteBufferPerfTest.MyByteOrder byteOrder,
|
||||||
|
boolean aligned,
|
||||||
|
ByteBufferPerfTest.MyBufferType bufferType)
|
||||||
|
throws Exception {
|
||||||
|
ByteBuffer src = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
|
ByteBuffer dst = ByteBufferPerfTest.newBuffer(byteOrder, aligned, bufferType);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(0);
|
src.position(0);
|
||||||
@@ -126,23 +122,25 @@ public class ByteBufferScalarVersusVectorPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeByteBufferBulkGet() throws Exception {
|
@Parameters({"true", "false"})
|
||||||
ByteBuffer src = ByteBuffer.allocate(mAligned ? 8192 : 8192 + 1);
|
public void timeByteBufferBulkGet(boolean aligned) throws Exception {
|
||||||
|
ByteBuffer src = ByteBuffer.allocate(aligned ? 8192 : 8192 + 1);
|
||||||
byte[] dst = new byte[8192];
|
byte[] dst = new byte[8192];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
src.get(dst, 0, dst.length);
|
src.get(dst, 0, dst.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDirectByteBufferBulkGet() throws Exception {
|
@Parameters({"true", "false"})
|
||||||
ByteBuffer src = ByteBuffer.allocateDirect(mAligned ? 8192 : 8192 + 1);
|
public void timeDirectByteBufferBulkGet(boolean aligned) throws Exception {
|
||||||
|
ByteBuffer src = ByteBuffer.allocateDirect(aligned ? 8192 : 8192 + 1);
|
||||||
byte[] dst = new byte[8192];
|
byte[] dst = new byte[8192];
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
src.position(mAligned ? 0 : 1);
|
src.position(aligned ? 0 : 1);
|
||||||
src.get(dst, 0, dst.length);
|
src.get(dst, 0, dst.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -34,13 +34,12 @@ import java.util.Collection;
|
|||||||
* Tests various Character methods, intended for testing multiple implementations against each
|
* Tests various Character methods, intended for testing multiple implementations against each
|
||||||
* other.
|
* other.
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class CharacterPerfTest {
|
public class CharacterPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mCharacterSet({0}), mOverload({1})")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{CharacterSet.ASCII, Overload.CHAR},
|
{CharacterSet.ASCII, Overload.CHAR},
|
||||||
@@ -50,17 +49,10 @@ public class CharacterPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public CharacterSet mCharacterSet;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public Overload mOverload;
|
|
||||||
|
|
||||||
private char[] mChars;
|
private char[] mChars;
|
||||||
|
|
||||||
@Before
|
public void setUp(CharacterSet characterSet) {
|
||||||
public void setUp() throws Exception {
|
this.mChars = characterSet.mChars;
|
||||||
this.mChars = mCharacterSet.mChars;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Overload {
|
public enum Overload {
|
||||||
@@ -87,10 +79,12 @@ public class CharacterPerfTest {
|
|||||||
|
|
||||||
// A fake benchmark to give us a baseline.
|
// A fake benchmark to give us a baseline.
|
||||||
@Test
|
@Test
|
||||||
public void timeIsSpace() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsSpace(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
boolean fake = false;
|
boolean fake = false;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
fake ^= ((char) ch == ' ');
|
fake ^= ((char) ch == ' ');
|
||||||
@@ -106,9 +100,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDigit() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeDigit(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.digit(mChars[ch], 10);
|
Character.digit(mChars[ch], 10);
|
||||||
@@ -124,9 +120,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGetNumericValue() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGetNumericValue(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.getNumericValue(mChars[ch]);
|
Character.getNumericValue(mChars[ch]);
|
||||||
@@ -142,9 +140,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsDigit() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsDigit(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isDigit(mChars[ch]);
|
Character.isDigit(mChars[ch]);
|
||||||
@@ -160,9 +160,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsIdentifierIgnorable() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsIdentifierIgnorable(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isIdentifierIgnorable(mChars[ch]);
|
Character.isIdentifierIgnorable(mChars[ch]);
|
||||||
@@ -178,9 +180,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsJavaIdentifierPart() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsJavaIdentifierPart(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isJavaIdentifierPart(mChars[ch]);
|
Character.isJavaIdentifierPart(mChars[ch]);
|
||||||
@@ -196,9 +200,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsJavaIdentifierStart() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsJavaIdentifierStart(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isJavaIdentifierStart(mChars[ch]);
|
Character.isJavaIdentifierStart(mChars[ch]);
|
||||||
@@ -214,9 +220,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsLetter() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsLetter(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isLetter(mChars[ch]);
|
Character.isLetter(mChars[ch]);
|
||||||
@@ -232,9 +240,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsLetterOrDigit() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsLetterOrDigit(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isLetterOrDigit(mChars[ch]);
|
Character.isLetterOrDigit(mChars[ch]);
|
||||||
@@ -250,9 +260,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsLowerCase() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsLowerCase(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isLowerCase(mChars[ch]);
|
Character.isLowerCase(mChars[ch]);
|
||||||
@@ -268,9 +280,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsSpaceChar() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsSpaceChar(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isSpaceChar(mChars[ch]);
|
Character.isSpaceChar(mChars[ch]);
|
||||||
@@ -286,9 +300,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsUpperCase() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsUpperCase(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isUpperCase(mChars[ch]);
|
Character.isUpperCase(mChars[ch]);
|
||||||
@@ -304,9 +320,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIsWhitespace() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIsWhitespace(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.isWhitespace(mChars[ch]);
|
Character.isWhitespace(mChars[ch]);
|
||||||
@@ -322,9 +340,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeToLowerCase() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeToLowerCase(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.toLowerCase(mChars[ch]);
|
Character.toLowerCase(mChars[ch]);
|
||||||
@@ -340,9 +360,11 @@ public class CharacterPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeToUpperCase() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeToUpperCase(CharacterSet characterSet, Overload overload) {
|
||||||
|
setUp(characterSet);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
if (mOverload == Overload.CHAR) {
|
if (overload == Overload.CHAR) {
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int ch = 0; ch < 65536; ++ch) {
|
for (int ch = 0; ch < 65536; ++ch) {
|
||||||
Character.toUpperCase(mChars[ch]);
|
Character.toUpperCase(mChars[ch]);
|
||||||
|
|||||||
@@ -20,44 +20,40 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class CharsetForNamePerfTest {
|
public class CharsetForNamePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "mCharsetName({0})")
|
public static String[] charsetNames() {
|
||||||
public static Collection<Object[]> data() {
|
return new String[] {
|
||||||
return Arrays.asList(
|
"UTF-16",
|
||||||
new Object[][] {
|
"UTF-8",
|
||||||
{"UTF-16"},
|
"UTF8",
|
||||||
{"UTF-8"},
|
"ISO-8859-1",
|
||||||
{"UTF8"},
|
"8859_1",
|
||||||
{"ISO-8859-1"},
|
"ISO-8859-2",
|
||||||
{"8859_1"},
|
"8859_2",
|
||||||
{"ISO-8859-2"},
|
"US-ASCII",
|
||||||
{"8859_2"},
|
"ASCII",
|
||||||
{"US-ASCII"},
|
};
|
||||||
{"ASCII"},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public String mCharsetName;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeCharsetForName() throws Exception {
|
@Parameters(method = "charsetNames")
|
||||||
|
public void timeCharsetForName(String charsetName) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Charset.forName(mCharsetName);
|
Charset.forName(charsetName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,22 +20,22 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class CharsetPerfTest {
|
public class CharsetPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mLength({0}), mName({1})")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{1, "UTF-16"},
|
{1, "UTF-16"},
|
||||||
@@ -86,24 +86,20 @@ public class CharsetPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int mLength;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public String mName;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_new_String_BString() throws Exception {
|
@Parameters(method = "getData")
|
||||||
byte[] bytes = makeBytes(makeString(mLength));
|
public void time_new_String_BString(int length, String name) throws Exception {
|
||||||
|
byte[] bytes = makeBytes(makeString(length));
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
new String(bytes, mName);
|
new String(bytes, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_new_String_BII() throws Exception {
|
@Parameters(method = "getData")
|
||||||
byte[] bytes = makeBytes(makeString(mLength));
|
public void time_new_String_BII(int length, String name) throws Exception {
|
||||||
|
byte[] bytes = makeBytes(makeString(length));
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
new String(bytes, 0, bytes.length);
|
new String(bytes, 0, bytes.length);
|
||||||
@@ -111,20 +107,22 @@ public class CharsetPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_new_String_BIIString() throws Exception {
|
@Parameters(method = "getData")
|
||||||
byte[] bytes = makeBytes(makeString(mLength));
|
public void time_new_String_BIIString(int length, String name) throws Exception {
|
||||||
|
byte[] bytes = makeBytes(makeString(length));
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
new String(bytes, 0, bytes.length, mName);
|
new String(bytes, 0, bytes.length, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_String_getBytes() throws Exception {
|
@Parameters(method = "getData")
|
||||||
String string = makeString(mLength);
|
public void time_String_getBytes(int length, String name) throws Exception {
|
||||||
|
String string = makeString(length);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
string.getBytes(mName);
|
string.getBytes(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
|
|
||||||
import java.security.spec.AlgorithmParameterSpec;
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -42,17 +43,13 @@ import javax.crypto.spec.IvParameterSpec;
|
|||||||
* Cipher benchmarks. Only runs on AES currently because of the combinatorial explosion of the test
|
* Cipher benchmarks. Only runs on AES currently because of the combinatorial explosion of the test
|
||||||
* as it stands.
|
* as it stands.
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class CipherPerfTest {
|
public class CipherPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameterized.Parameters(
|
public static Collection getCases() {
|
||||||
name =
|
int[] keySizes = new int[] {128, 192, 256};
|
||||||
"mMode({0}), mPadding({1}), mKeySize({2}), mInputSize({3}),"
|
|
||||||
+ " mImplementation({4})")
|
|
||||||
public static Collection cases() {
|
|
||||||
int[] mKeySizes = new int[] {128, 192, 256};
|
|
||||||
int[] inputSizes = new int[] {16, 32, 64, 128, 1024, 8192};
|
int[] inputSizes = new int[] {16, 32, 64, 128, 1024, 8192};
|
||||||
final List<Object[]> params = new ArrayList<>();
|
final List<Object[]> params = new ArrayList<>();
|
||||||
for (Mode mode : Mode.values()) {
|
for (Mode mode : Mode.values()) {
|
||||||
@@ -71,11 +68,11 @@ public class CipherPerfTest {
|
|||||||
&& implementation == Implementation.OpenSSL) {
|
&& implementation == Implementation.OpenSSL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (int mKeySize : mKeySizes) {
|
for (int keySize : keySizes) {
|
||||||
for (int inputSize : inputSizes) {
|
for (int inputSize : inputSizes) {
|
||||||
params.add(
|
params.add(
|
||||||
new Object[] {
|
new Object[] {
|
||||||
mode, padding, mKeySize, inputSize, implementation
|
mode, padding, keySize, inputSize, implementation
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,9 +104,6 @@ public class CipherPerfTest {
|
|||||||
AES,
|
AES,
|
||||||
};
|
};
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Mode mMode;
|
|
||||||
|
|
||||||
public enum Mode {
|
public enum Mode {
|
||||||
CBC,
|
CBC,
|
||||||
CFB,
|
CFB,
|
||||||
@@ -118,23 +112,11 @@ public class CipherPerfTest {
|
|||||||
OFB,
|
OFB,
|
||||||
};
|
};
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public Padding mPadding;
|
|
||||||
|
|
||||||
public enum Padding {
|
public enum Padding {
|
||||||
NOPADDING,
|
NOPADDING,
|
||||||
PKCS1PADDING,
|
PKCS1PADDING,
|
||||||
};
|
};
|
||||||
|
|
||||||
@Parameterized.Parameter(2)
|
|
||||||
public int mKeySize;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(3)
|
|
||||||
public int mInputSize;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(4)
|
|
||||||
public Implementation mImplementation;
|
|
||||||
|
|
||||||
public enum Implementation {
|
public enum Implementation {
|
||||||
OpenSSL,
|
OpenSSL,
|
||||||
BouncyCastle
|
BouncyCastle
|
||||||
@@ -156,21 +138,20 @@ public class CipherPerfTest {
|
|||||||
|
|
||||||
private AlgorithmParameterSpec mSpec;
|
private AlgorithmParameterSpec mSpec;
|
||||||
|
|
||||||
@Before
|
public void setUp(Mode mode, Padding padding, int keySize, Implementation implementation)
|
||||||
public void setUp() throws Exception {
|
throws Exception {
|
||||||
mCipherAlgorithm =
|
mCipherAlgorithm = mAlgorithm.toString() + "/" + mode.toString() + "/" + padding.toString();
|
||||||
mAlgorithm.toString() + "/" + mMode.toString() + "/" + mPadding.toString();
|
|
||||||
|
|
||||||
String mKeyAlgorithm = mAlgorithm.toString();
|
String mKeyAlgorithm = mAlgorithm.toString();
|
||||||
mKey = sKeySizes.get(mKeySize);
|
mKey = sKeySizes.get(keySize);
|
||||||
if (mKey == null) {
|
if (mKey == null) {
|
||||||
KeyGenerator generator = KeyGenerator.getInstance(mKeyAlgorithm);
|
KeyGenerator generator = KeyGenerator.getInstance(mKeyAlgorithm);
|
||||||
generator.init(mKeySize);
|
generator.init(keySize);
|
||||||
mKey = generator.generateKey();
|
mKey = generator.generateKey();
|
||||||
sKeySizes.put(mKeySize, mKey);
|
sKeySizes.put(keySize, mKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (mImplementation) {
|
switch (implementation) {
|
||||||
case OpenSSL:
|
case OpenSSL:
|
||||||
mProviderName = "AndroidOpenSSL";
|
mProviderName = "AndroidOpenSSL";
|
||||||
break;
|
break;
|
||||||
@@ -178,10 +159,10 @@ public class CipherPerfTest {
|
|||||||
mProviderName = "BC";
|
mProviderName = "BC";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException(mImplementation.toString());
|
throw new RuntimeException(implementation.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mMode != Mode.ECB) {
|
if (mode != Mode.ECB) {
|
||||||
mSpec = new IvParameterSpec(IV);
|
mSpec = new IvParameterSpec(IV);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,18 +174,26 @@ public class CipherPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeEncrypt() throws Exception {
|
@Parameters(method = "getCases")
|
||||||
|
public void timeEncrypt(
|
||||||
|
Mode mode, Padding padding, int keySize, int inputSize, Implementation implementation)
|
||||||
|
throws Exception {
|
||||||
|
setUp(mode, padding, keySize, implementation);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mCipherEncrypt.doFinal(DATA, 0, mInputSize, mOutput);
|
mCipherEncrypt.doFinal(DATA, 0, inputSize, mOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDecrypt() throws Exception {
|
@Parameters(method = "getCases")
|
||||||
|
public void timeDecrypt(
|
||||||
|
Mode mode, Padding padding, int keySize, int inputSize, Implementation implementation)
|
||||||
|
throws Exception {
|
||||||
|
setUp(mode, padding, keySize, implementation);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mCipherDecrypt.doFinal(DATA, 0, mInputSize, mOutput);
|
mCipherDecrypt.doFinal(DATA, 0, inputSize, mOutput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -35,19 +36,15 @@ import java.util.List;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class CollectionsPerfTest {
|
public class CollectionsPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mArrayListLength({0})")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{4}, {16}, {64}, {256}, {1024}});
|
return Arrays.asList(new Object[][] {{4}, {16}, {64}, {256}, {1024}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int arrayListLength;
|
|
||||||
|
|
||||||
public static Comparator<Integer> REVERSE =
|
public static Comparator<Integer> REVERSE =
|
||||||
new Comparator<Integer>() {
|
new Comparator<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
@@ -59,7 +56,8 @@ public class CollectionsPerfTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSort_arrayList() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSort_arrayList(int arrayListLength) throws Exception {
|
||||||
List<Integer> input = buildList(arrayListLength, ArrayList.class);
|
List<Integer> input = buildList(arrayListLength, ArrayList.class);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -68,7 +66,8 @@ public class CollectionsPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSortWithComparator_arrayList() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSortWithComparator_arrayList(int arrayListLength) throws Exception {
|
||||||
List<Integer> input = buildList(arrayListLength, ArrayList.class);
|
List<Integer> input = buildList(arrayListLength, ArrayList.class);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -77,7 +76,8 @@ public class CollectionsPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSort_vector() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSort_vector(int arrayListLength) throws Exception {
|
||||||
List<Integer> input = buildList(arrayListLength, Vector.class);
|
List<Integer> input = buildList(arrayListLength, Vector.class);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
@@ -86,7 +86,8 @@ public class CollectionsPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSortWithComparator_vector() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSortWithComparator_vector(int arrayListLength) throws Exception {
|
||||||
List<Integer> input = buildList(arrayListLength, Vector.class);
|
List<Integer> input = buildList(arrayListLength, Vector.class);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -32,29 +33,32 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public final class EqualsHashCodePerfTest {
|
public final class EqualsHashCodePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
private enum Type {
|
private enum Type {
|
||||||
URI() {
|
URI() {
|
||||||
@Override Object newInstance(String text) throws Exception {
|
@Override
|
||||||
|
Object newInstance(String text) throws Exception {
|
||||||
return new URI(text);
|
return new URI(text);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
URL() {
|
URL() {
|
||||||
@Override Object newInstance(String text) throws Exception {
|
@Override
|
||||||
|
Object newInstance(String text) throws Exception {
|
||||||
return new URL(text);
|
return new URL(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract Object newInstance(String text) throws Exception;
|
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";
|
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";
|
||||||
|
|
||||||
@Parameterized.Parameters(name = "mType({0})")
|
public static Collection getCases() {
|
||||||
public static Collection cases() {
|
|
||||||
final List<Object[]> params = new ArrayList<>();
|
final List<Object[]> params = new ArrayList<>();
|
||||||
for (Type type : Type.values()) {
|
for (Type type : Type.values()) {
|
||||||
params.add(new Object[] {type});
|
params.add(new Object[] {type});
|
||||||
@@ -62,9 +66,6 @@ public final class EqualsHashCodePerfTest {
|
|||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Type mType;
|
|
||||||
|
|
||||||
Object mA1;
|
Object mA1;
|
||||||
Object mA2;
|
Object mA2;
|
||||||
Object mB1;
|
Object mB1;
|
||||||
@@ -73,20 +74,13 @@ public final class EqualsHashCodePerfTest {
|
|||||||
Object mC1;
|
Object mC1;
|
||||||
Object mC2;
|
Object mC2;
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
mA1 = mType.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
|
|
||||||
mA2 = mType.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
|
|
||||||
mB1 = mType.newInstance("http://developer.android.com/reference/java/net/URI.html");
|
|
||||||
mB2 = mType.newInstance("http://developer.android.com/reference/java/net/URI.html");
|
|
||||||
|
|
||||||
mC1 = mType.newInstance("http://developer.android.com/query?q=" + QUERY);
|
|
||||||
// Replace the very last char.
|
|
||||||
mC2 = mType.newInstance("http://developer.android.com/query?q=" + QUERY.substring(0, QUERY.length() - 3) + "%AF");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeEquals() {
|
@Parameters(method = "getCases")
|
||||||
|
public void timeEquals(Type type) throws Exception {
|
||||||
|
mA1 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
|
||||||
|
mA2 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
|
||||||
|
mB1 = type.newInstance("http://developer.android.com/reference/java/net/URI.html");
|
||||||
|
mB2 = type.newInstance("http://developer.android.com/reference/java/net/URI.html");
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mA1.equals(mB1);
|
mA1.equals(mB1);
|
||||||
@@ -96,7 +90,10 @@ public final class EqualsHashCodePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeHashCode() {
|
@Parameters(method = "getCases")
|
||||||
|
public void timeHashCode(Type type) throws Exception {
|
||||||
|
mA1 = type.newInstance("https://mail.google.com/mail/u/0/?shva=1#inbox");
|
||||||
|
mB1 = type.newInstance("http://developer.android.com/reference/java/net/URI.html");
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mA1.hashCode();
|
mA1.hashCode();
|
||||||
@@ -105,7 +102,15 @@ public final class EqualsHashCodePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeEqualsWithHeavilyEscapedComponent() {
|
@Parameters(method = "getCases")
|
||||||
|
public void timeEqualsWithHeavilyEscapedComponent(Type type) throws Exception {
|
||||||
|
mC1 = type.newInstance("http://developer.android.com/query?q=" + QUERY);
|
||||||
|
// Replace the very last char.
|
||||||
|
mC2 =
|
||||||
|
type.newInstance(
|
||||||
|
"http://developer.android.com/query?q="
|
||||||
|
+ QUERY.substring(0, QUERY.length() - 3)
|
||||||
|
+ "%AF");
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mC1.equals(mC2);
|
mC1.equals(mC2);
|
||||||
|
|||||||
@@ -20,26 +20,24 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.KeyPairGenerator;
|
import java.security.KeyPairGenerator;
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class KeyPairGeneratorPerfTest {
|
public class KeyPairGeneratorPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mAlgorithm={0}, mImplementation={1}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{Algorithm.RSA, Implementation.BouncyCastle},
|
{Algorithm.RSA, Implementation.BouncyCastle},
|
||||||
@@ -48,12 +46,6 @@ public class KeyPairGeneratorPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Algorithm mAlgorithm;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public Implementation mImplementation;
|
|
||||||
|
|
||||||
public enum Algorithm {
|
public enum Algorithm {
|
||||||
RSA,
|
RSA,
|
||||||
DSA,
|
DSA,
|
||||||
@@ -66,26 +58,25 @@ public class KeyPairGeneratorPerfTest {
|
|||||||
|
|
||||||
private String mGeneratorAlgorithm;
|
private String mGeneratorAlgorithm;
|
||||||
private KeyPairGenerator mGenerator;
|
private KeyPairGenerator mGenerator;
|
||||||
private SecureRandom mRandom;
|
|
||||||
|
|
||||||
@Before
|
public void setUp(Algorithm algorithm, Implementation implementation) throws Exception {
|
||||||
public void setUp() throws Exception {
|
this.mGeneratorAlgorithm = algorithm.toString();
|
||||||
this.mGeneratorAlgorithm = mAlgorithm.toString();
|
|
||||||
|
|
||||||
final String provider;
|
final String provider;
|
||||||
if (mImplementation == Implementation.BouncyCastle) {
|
if (implementation == Implementation.BouncyCastle) {
|
||||||
provider = "BC";
|
provider = "BC";
|
||||||
} else {
|
} else {
|
||||||
provider = "AndroidOpenSSL";
|
provider = "AndroidOpenSSL";
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mGenerator = KeyPairGenerator.getInstance(mGeneratorAlgorithm, provider);
|
this.mGenerator = KeyPairGenerator.getInstance(mGeneratorAlgorithm, provider);
|
||||||
this.mRandom = SecureRandom.getInstance("SHA1PRNG");
|
|
||||||
this.mGenerator.initialize(1024);
|
this.mGenerator.initialize(1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void time(Algorithm algorithm, Implementation implementation) throws Exception {
|
||||||
|
setUp(algorithm, implementation);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
KeyPair keyPair = mGenerator.generateKeyPair();
|
KeyPair keyPair = mGenerator.generateKeyPair();
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -34,36 +35,34 @@ import java.util.Collection;
|
|||||||
*
|
*
|
||||||
* @author Kevin Bourrillion
|
* @author Kevin Bourrillion
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class LoopingBackwardsPerfTest {
|
public class LoopingBackwardsPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mMax={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{2}, {20}, {2000}, {20000000}});
|
return Arrays.asList(new Object[][] {{2}, {20}, {2000}, {20000000}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int mMax;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeForwards() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeForwards(int max) {
|
||||||
int fake = 0;
|
int fake = 0;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int j = 0; j < mMax; j++) {
|
for (int j = 0; j < max; j++) {
|
||||||
fake += j;
|
fake += j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeBackwards() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeBackwards(int max) {
|
||||||
int fake = 0;
|
int fake = 0;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int j = mMax - 1; j >= 0; j--) {
|
for (int j = max - 1; j >= 0; j--) {
|
||||||
fake += j;
|
fake += j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class MessageDigestPerfTest {
|
public class MessageDigestPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mAlgorithm={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{Algorithm.MD5},
|
{Algorithm.MD5},
|
||||||
@@ -48,9 +48,6 @@ public class MessageDigestPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Algorithm mAlgorithm;
|
|
||||||
|
|
||||||
public String mProvider = "AndroidOpenSSL";
|
public String mProvider = "AndroidOpenSSL";
|
||||||
|
|
||||||
private static final int DATA_SIZE = 8192;
|
private static final int DATA_SIZE = 8192;
|
||||||
@@ -97,44 +94,44 @@ public class MessageDigestPerfTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void time(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
digest.update(DATA, 0, DATA_SIZE);
|
digest.update(DATA, 0, DATA_SIZE);
|
||||||
digest.digest();
|
digest.digest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeLargeArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeLargeArray(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
digest.update(LARGE_DATA, 0, LARGE_DATA_SIZE);
|
digest.update(LARGE_DATA, 0, LARGE_DATA_SIZE);
|
||||||
digest.digest();
|
digest.digest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSmallChunkOfLargeArray() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSmallChunkOfLargeArray(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
digest.update(LARGE_DATA, LARGE_DATA_SIZE / 2, DATA_SIZE);
|
digest.update(LARGE_DATA, LARGE_DATA_SIZE / 2, DATA_SIZE);
|
||||||
digest.digest();
|
digest.digest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSmallByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSmallByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
SMALL_BUFFER.position(0);
|
SMALL_BUFFER.position(0);
|
||||||
SMALL_BUFFER.limit(SMALL_BUFFER.capacity());
|
SMALL_BUFFER.limit(SMALL_BUFFER.capacity());
|
||||||
digest.update(SMALL_BUFFER);
|
digest.update(SMALL_BUFFER);
|
||||||
@@ -143,11 +140,11 @@ public class MessageDigestPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSmallDirectByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSmallDirectByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
SMALL_DIRECT_BUFFER.position(0);
|
SMALL_DIRECT_BUFFER.position(0);
|
||||||
SMALL_DIRECT_BUFFER.limit(SMALL_DIRECT_BUFFER.capacity());
|
SMALL_DIRECT_BUFFER.limit(SMALL_DIRECT_BUFFER.capacity());
|
||||||
digest.update(SMALL_DIRECT_BUFFER);
|
digest.update(SMALL_DIRECT_BUFFER);
|
||||||
@@ -156,11 +153,11 @@ public class MessageDigestPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeLargeByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeLargeByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
LARGE_BUFFER.position(0);
|
LARGE_BUFFER.position(0);
|
||||||
LARGE_BUFFER.limit(LARGE_BUFFER.capacity());
|
LARGE_BUFFER.limit(LARGE_BUFFER.capacity());
|
||||||
digest.update(LARGE_BUFFER);
|
digest.update(LARGE_BUFFER);
|
||||||
@@ -169,11 +166,11 @@ public class MessageDigestPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeLargeDirectByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeLargeDirectByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
LARGE_DIRECT_BUFFER.position(0);
|
LARGE_DIRECT_BUFFER.position(0);
|
||||||
LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.capacity());
|
LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.capacity());
|
||||||
digest.update(LARGE_DIRECT_BUFFER);
|
digest.update(LARGE_DIRECT_BUFFER);
|
||||||
@@ -182,11 +179,11 @@ public class MessageDigestPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSmallChunkOfLargeByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSmallChunkOfLargeByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
LARGE_BUFFER.position(LARGE_BUFFER.capacity() / 2);
|
LARGE_BUFFER.position(LARGE_BUFFER.capacity() / 2);
|
||||||
LARGE_BUFFER.limit(LARGE_BUFFER.position() + DATA_SIZE);
|
LARGE_BUFFER.limit(LARGE_BUFFER.position() + DATA_SIZE);
|
||||||
digest.update(LARGE_BUFFER);
|
digest.update(LARGE_BUFFER);
|
||||||
@@ -195,11 +192,11 @@ public class MessageDigestPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSmallChunkOfLargeDirectByteBuffer() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSmallChunkOfLargeDirectByteBuffer(Algorithm algorithm) throws Exception {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
MessageDigest digest =
|
MessageDigest digest = MessageDigest.getInstance(algorithm.toString(), mProvider);
|
||||||
MessageDigest.getInstance(mAlgorithm.toString(), mProvider);
|
|
||||||
LARGE_DIRECT_BUFFER.position(LARGE_DIRECT_BUFFER.capacity() / 2);
|
LARGE_DIRECT_BUFFER.position(LARGE_DIRECT_BUFFER.capacity() / 2);
|
||||||
LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.position() + DATA_SIZE);
|
LARGE_DIRECT_BUFFER.limit(LARGE_DIRECT_BUFFER.position() + DATA_SIZE);
|
||||||
digest.update(LARGE_DIRECT_BUFFER);
|
digest.update(LARGE_DIRECT_BUFFER);
|
||||||
|
|||||||
@@ -20,17 +20,18 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public final class MutableIntPerfTest {
|
public final class MutableIntPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -96,29 +97,28 @@ public final class MutableIntPerfTest {
|
|||||||
abstract int timeGet(BenchmarkState state);
|
abstract int timeGet(BenchmarkState state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mKind={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{Kind.ARRAY}, {Kind.ATOMIC}});
|
return Arrays.asList(new Object[][] {{Kind.ARRAY}, {Kind.ATOMIC}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Kind mKind;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeCreate() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeCreate(Kind kind) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
mKind.timeCreate(state);
|
kind.timeCreate(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeIncrement() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeIncrement(Kind kind) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
mKind.timeIncrement(state);
|
kind.timeIncrement(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGet() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGet(Kind kind) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
mKind.timeGet(state);
|
kind.timeGet(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -35,13 +35,12 @@ import java.util.List;
|
|||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class PriorityQueuePerfTest {
|
public class PriorityQueuePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mQueueSize={0}, mHitRate={1}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{100, 0},
|
{100, 0},
|
||||||
@@ -62,26 +61,19 @@ public class PriorityQueuePerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int mQueueSize;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public int mHitRate;
|
|
||||||
|
|
||||||
private PriorityQueue<Integer> mPq;
|
private PriorityQueue<Integer> mPq;
|
||||||
private PriorityQueue<Integer> mUsepq;
|
private PriorityQueue<Integer> mUsepq;
|
||||||
private List<Integer> mSeekElements;
|
private List<Integer> mSeekElements;
|
||||||
private Random mRandom = new Random(189279387L);
|
private Random mRandom = new Random(189279387L);
|
||||||
|
|
||||||
@Before
|
public void setUp(int queueSize, int hitRate) throws Exception {
|
||||||
public void setUp() throws Exception {
|
|
||||||
mPq = new PriorityQueue<Integer>();
|
mPq = new PriorityQueue<Integer>();
|
||||||
mUsepq = new PriorityQueue<Integer>();
|
mUsepq = new PriorityQueue<Integer>();
|
||||||
mSeekElements = new ArrayList<Integer>();
|
mSeekElements = new ArrayList<Integer>();
|
||||||
List<Integer> allElements = new ArrayList<Integer>();
|
List<Integer> allElements = new ArrayList<Integer>();
|
||||||
int numShared = (int) (mQueueSize * ((double) mHitRate / 100));
|
int numShared = (int) (queueSize * ((double) hitRate / 100));
|
||||||
// the total number of elements we require to engineer a hit rate of mHitRate%
|
// the total number of elements we require to engineer a hit rate of hitRate%
|
||||||
int totalElements = 2 * mQueueSize - numShared;
|
int totalElements = 2 * queueSize - numShared;
|
||||||
for (int i = 0; i < totalElements; i++) {
|
for (int i = 0; i < totalElements; i++) {
|
||||||
allElements.add(i);
|
allElements.add(i);
|
||||||
}
|
}
|
||||||
@@ -93,11 +85,11 @@ public class PriorityQueuePerfTest {
|
|||||||
mSeekElements.add(allElements.get(i));
|
mSeekElements.add(allElements.get(i));
|
||||||
}
|
}
|
||||||
// add priority queue only elements (these won't be touched)
|
// add priority queue only elements (these won't be touched)
|
||||||
for (int i = numShared; i < mQueueSize; i++) {
|
for (int i = numShared; i < queueSize; i++) {
|
||||||
mPq.add(allElements.get(i));
|
mPq.add(allElements.get(i));
|
||||||
}
|
}
|
||||||
// add non-priority queue elements (these will be misses)
|
// add non-priority queue elements (these will be misses)
|
||||||
for (int i = mQueueSize; i < totalElements; i++) {
|
for (int i = queueSize; i < totalElements; i++) {
|
||||||
mSeekElements.add(allElements.get(i));
|
mSeekElements.add(allElements.get(i));
|
||||||
}
|
}
|
||||||
mUsepq = new PriorityQueue<Integer>(mPq);
|
mUsepq = new PriorityQueue<Integer>(mPq);
|
||||||
@@ -107,16 +99,18 @@ public class PriorityQueuePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeRemove() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeRemove(int queueSize, int hitRate) throws Exception {
|
||||||
|
setUp(queueSize, hitRate);
|
||||||
boolean fake = false;
|
boolean fake = false;
|
||||||
int elementsSize = mSeekElements.size();
|
int elementsSize = mSeekElements.size();
|
||||||
// At most allow the queue to empty 10%.
|
// At most allow the queue to empty 10%.
|
||||||
int resizingThreshold = mQueueSize / 10;
|
int resizingThreshold = queueSize / 10;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
// Reset queue every so often. This will be called more often for smaller
|
// Reset queue every so often. This will be called more often for smaller
|
||||||
// mQueueSizes, but since a copy is linear, it will also cost proportionally
|
// queueSizes, but since a copy is linear, it will also cost proportionally
|
||||||
// less, and hopefully it will approximately balance out.
|
// less, and hopefully it will approximately balance out.
|
||||||
if (++i % resizingThreshold == 0) {
|
if (++i % resizingThreshold == 0) {
|
||||||
mUsepq = new PriorityQueue<Integer>(mPq);
|
mUsepq = new PriorityQueue<Integer>(mPq);
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -32,7 +33,7 @@ import java.util.Locale;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public final class SchemePrefixPerfTest {
|
public final class SchemePrefixPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -85,19 +86,16 @@ public final class SchemePrefixPerfTest {
|
|||||||
abstract String execute(String spec);
|
abstract String execute(String spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mStrategy={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(new Object[][] {{Strategy.REGEX}, {Strategy.JAVA}});
|
return Arrays.asList(new Object[][] {{Strategy.REGEX}, {Strategy.JAVA}});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Strategy mStrategy;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSchemePrefix() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSchemePrefix(Strategy strategy) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStrategy.execute("http://android.com");
|
strategy.execute("http://android.com");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.KeyPairGenerator;
|
import java.security.KeyPairGenerator;
|
||||||
@@ -37,13 +37,12 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/** Tests RSA and DSA mSignature creation and verification. */
|
/** Tests RSA and DSA mSignature creation and verification. */
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class SignaturePerfTest {
|
public class SignaturePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mAlgorithm={0}, mImplementation={1}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{Algorithm.MD5WithRSA, Implementation.OpenSSL},
|
{Algorithm.MD5WithRSA, Implementation.OpenSSL},
|
||||||
@@ -55,12 +54,6 @@ public class SignaturePerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public Algorithm mAlgorithm;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public Implementation mImplementation;
|
|
||||||
|
|
||||||
private static final int DATA_SIZE = 8192;
|
private static final int DATA_SIZE = 8192;
|
||||||
private static final byte[] DATA = new byte[DATA_SIZE];
|
private static final byte[] DATA = new byte[DATA_SIZE];
|
||||||
|
|
||||||
@@ -94,9 +87,8 @@ public class SignaturePerfTest {
|
|||||||
private PrivateKey mPrivateKey;
|
private PrivateKey mPrivateKey;
|
||||||
private PublicKey mPublicKey;
|
private PublicKey mPublicKey;
|
||||||
|
|
||||||
@Before
|
public void setUp(Algorithm algorithm) throws Exception {
|
||||||
public void setUp() throws Exception {
|
this.mSignatureAlgorithm = algorithm.toString();
|
||||||
this.mSignatureAlgorithm = mAlgorithm.toString();
|
|
||||||
|
|
||||||
String keyAlgorithm =
|
String keyAlgorithm =
|
||||||
mSignatureAlgorithm.substring(
|
mSignatureAlgorithm.substring(
|
||||||
@@ -121,11 +113,13 @@ public class SignaturePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeSign() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeSign(Algorithm algorithm, Implementation implementation) throws Exception {
|
||||||
|
setUp(algorithm);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Signature signer;
|
Signature signer;
|
||||||
switch (mImplementation) {
|
switch (implementation) {
|
||||||
case OpenSSL:
|
case OpenSSL:
|
||||||
signer = Signature.getInstance(mSignatureAlgorithm, "AndroidOpenSSL");
|
signer = Signature.getInstance(mSignatureAlgorithm, "AndroidOpenSSL");
|
||||||
break;
|
break;
|
||||||
@@ -133,7 +127,7 @@ public class SignaturePerfTest {
|
|||||||
signer = Signature.getInstance(mSignatureAlgorithm, "BC");
|
signer = Signature.getInstance(mSignatureAlgorithm, "BC");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException(mImplementation.toString());
|
throw new RuntimeException(implementation.toString());
|
||||||
}
|
}
|
||||||
signer.initSign(mPrivateKey);
|
signer.initSign(mPrivateKey);
|
||||||
signer.update(DATA);
|
signer.update(DATA);
|
||||||
@@ -142,11 +136,13 @@ public class SignaturePerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeVerify() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeVerify(Algorithm algorithm, Implementation implementation) throws Exception {
|
||||||
|
setUp(algorithm);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Signature verifier;
|
Signature verifier;
|
||||||
switch (mImplementation) {
|
switch (implementation) {
|
||||||
case OpenSSL:
|
case OpenSSL:
|
||||||
verifier = Signature.getInstance(mSignatureAlgorithm, "AndroidOpenSSL");
|
verifier = Signature.getInstance(mSignatureAlgorithm, "AndroidOpenSSL");
|
||||||
break;
|
break;
|
||||||
@@ -154,7 +150,7 @@ public class SignaturePerfTest {
|
|||||||
verifier = Signature.getInstance(mSignatureAlgorithm, "BC");
|
verifier = Signature.getInstance(mSignatureAlgorithm, "BC");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException(mImplementation.toString());
|
throw new RuntimeException(implementation.toString());
|
||||||
}
|
}
|
||||||
verifier.initVerify(mPublicKey);
|
verifier.initVerify(mPublicKey);
|
||||||
verifier.update(DATA);
|
verifier.update(DATA);
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class StringPerfTest {
|
public class StringPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -46,8 +47,7 @@ public class StringPerfTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mStringLengths={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{StringLengths.EIGHT_KI},
|
{StringLengths.EIGHT_KI},
|
||||||
@@ -57,9 +57,6 @@ public class StringPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public StringLengths mStringLengths;
|
|
||||||
|
|
||||||
private static String makeString(int length) {
|
private static String makeString(int length) {
|
||||||
StringBuilder result = new StringBuilder(length);
|
StringBuilder result = new StringBuilder(length);
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
@@ -69,10 +66,11 @@ public class StringPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeHashCode() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeHashCode(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.hashCode();
|
stringLengths.mValue.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class StringReplaceAllPerfTest {
|
public class StringReplaceAllPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -69,8 +70,7 @@ public class StringReplaceAllPerfTest {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mStringLengths={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{StringLengths.BOOT_IMAGE},
|
{StringLengths.BOOT_IMAGE},
|
||||||
@@ -82,30 +82,30 @@ public class StringReplaceAllPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public StringLengths mStringLengths;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceAllTrivialPatternNonExistent() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceAllTrivialPatternNonExistent(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replaceAll("fish", "0");
|
stringLengths.mValue.replaceAll("fish", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceTrivialPatternAllRepeated() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceTrivialPatternAllRepeated(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replaceAll("jklm", "0");
|
stringLengths.mValue.replaceAll("jklm", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceAllTrivialPatternSingleOccurrence() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceAllTrivialPatternSingleOccurrence(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replaceAll("qrst", "0");
|
stringLengths.mValue.replaceAll("qrst", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class StringReplacePerfTest {
|
public class StringReplacePerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -64,8 +65,7 @@ public class StringReplacePerfTest {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mStringLengths={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{StringLengths.EMPTY},
|
{StringLengths.EMPTY},
|
||||||
@@ -76,54 +76,57 @@ public class StringReplacePerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public StringLengths mStringLengths;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceCharNonExistent() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceCharNonExistent(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace('z', '0');
|
stringLengths.mValue.replace('z', '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceCharRepeated() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceCharRepeated(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace('a', '0');
|
stringLengths.mValue.replace('a', '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceSingleChar() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceSingleChar(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace('q', '0');
|
stringLengths.mValue.replace('q', '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceSequenceNonExistent() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceSequenceNonExistent(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace("fish", "0");
|
stringLengths.mValue.replace("fish", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceSequenceRepeated() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceSequenceRepeated(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace("jklm", "0");
|
stringLengths.mValue.replace("jklm", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeReplaceSingleSequence() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeReplaceSingleSequence(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.replace("qrst", "0");
|
stringLengths.mValue.replace("qrst", "0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,17 +20,18 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class StringToBytesPerfTest {
|
public class StringToBytesPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
@@ -53,8 +54,7 @@ public class StringToBytesPerfTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name = "mStringLengths={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{StringLengths.EMPTY},
|
{StringLengths.EMPTY},
|
||||||
@@ -69,9 +69,6 @@ public class StringToBytesPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public StringLengths mStringLengths;
|
|
||||||
|
|
||||||
private static String makeString(int length) {
|
private static String makeString(int length) {
|
||||||
char[] chars = new char[length];
|
char[] chars = new char[length];
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
@@ -89,26 +86,29 @@ public class StringToBytesPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGetBytesUtf8() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGetBytesUtf8(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.getBytes(StandardCharsets.UTF_8);
|
stringLengths.mValue.getBytes(StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGetBytesIso88591() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGetBytesIso88591(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.getBytes(StandardCharsets.ISO_8859_1);
|
stringLengths.mValue.getBytes(StandardCharsets.ISO_8859_1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeGetBytesAscii() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeGetBytesAscii(StringLengths stringLengths) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
mStringLengths.mValue.getBytes(StandardCharsets.US_ASCII);
|
stringLengths.mValue.getBytes(StandardCharsets.US_ASCII);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,22 +20,22 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public class StringToRealPerfTest {
|
public class StringToRealPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mString={0}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{"NaN"},
|
{"NaN"},
|
||||||
@@ -49,22 +49,21 @@ public class StringToRealPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public String mString;
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeFloat_parseFloat() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeFloat_parseFloat(String string) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Float.parseFloat(mString);
|
Float.parseFloat(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDouble_parseDouble() {
|
@Parameters(method = "getData")
|
||||||
|
public void timeDouble_parseDouble(String string) {
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
Double.parseDouble(mString);
|
Double.parseDouble(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState;
|
|||||||
import android.perftests.utils.PerfStatusReporter;
|
import android.perftests.utils.PerfStatusReporter;
|
||||||
import android.test.suitebuilder.annotation.LargeTest;
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
import org.junit.Before;
|
import junitparams.JUnitParamsRunner;
|
||||||
|
import junitparams.Parameters;
|
||||||
|
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
import org.xmlpull.v1.XmlPullParserFactory;
|
||||||
@@ -38,13 +38,12 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
// http://code.google.com/p/android/issues/detail?id=18102
|
// http://code.google.com/p/android/issues/detail?id=18102
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(JUnitParamsRunner.class)
|
||||||
@LargeTest
|
@LargeTest
|
||||||
public final class XMLEntitiesPerfTest {
|
public final class XMLEntitiesPerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
@Parameters(name = "mLength={0}, mEntityFraction={1}")
|
public static Collection<Object[]> getData() {
|
||||||
public static Collection<Object[]> data() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{10, 0},
|
{10, 0},
|
||||||
@@ -59,29 +58,22 @@ public final class XMLEntitiesPerfTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameterized.Parameter(0)
|
|
||||||
public int mLength;
|
|
||||||
|
|
||||||
@Parameterized.Parameter(1)
|
|
||||||
public float mEntityFraction;
|
|
||||||
|
|
||||||
private XmlPullParserFactory mXmlPullParserFactory;
|
private XmlPullParserFactory mXmlPullParserFactory;
|
||||||
private DocumentBuilderFactory mDocumentBuilderFactory;
|
private DocumentBuilderFactory mDocumentBuilderFactory;
|
||||||
|
|
||||||
/** a string like {@code <doc>&&++</doc>}. */
|
/** a string like {@code <doc>&&++</doc>}. */
|
||||||
private String mXml;
|
private String mXml;
|
||||||
|
|
||||||
@Before
|
public void setUp(int length, float entityFraction) throws Exception {
|
||||||
public void setUp() throws Exception {
|
|
||||||
mXmlPullParserFactory = XmlPullParserFactory.newInstance();
|
mXmlPullParserFactory = XmlPullParserFactory.newInstance();
|
||||||
mDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
|
mDocumentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
|
||||||
StringBuilder xmlBuilder = new StringBuilder();
|
StringBuilder xmlBuilder = new StringBuilder();
|
||||||
xmlBuilder.append("<doc>");
|
xmlBuilder.append("<doc>");
|
||||||
for (int i = 0; i < (mLength * mEntityFraction); i++) {
|
for (int i = 0; i < (length * entityFraction); i++) {
|
||||||
xmlBuilder.append("&");
|
xmlBuilder.append("&");
|
||||||
}
|
}
|
||||||
while (xmlBuilder.length() < mLength) {
|
while (xmlBuilder.length() < length) {
|
||||||
xmlBuilder.append("+");
|
xmlBuilder.append("+");
|
||||||
}
|
}
|
||||||
xmlBuilder.append("</doc>");
|
xmlBuilder.append("</doc>");
|
||||||
@@ -89,7 +81,9 @@ public final class XMLEntitiesPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeXmlParser() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeXmlParser(int length, float entityFraction) throws Exception {
|
||||||
|
setUp(length, entityFraction);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
XmlPullParser parser = mXmlPullParserFactory.newPullParser();
|
XmlPullParser parser = mXmlPullParserFactory.newPullParser();
|
||||||
@@ -101,7 +95,9 @@ public final class XMLEntitiesPerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void timeDocumentBuilder() throws Exception {
|
@Parameters(method = "getData")
|
||||||
|
public void timeDocumentBuilder(int length, float entityFraction) throws Exception {
|
||||||
|
setUp(length, entityFraction);
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
DocumentBuilder documentBuilder = mDocumentBuilderFactory.newDocumentBuilder();
|
DocumentBuilder documentBuilder = mDocumentBuilderFactory.newDocumentBuilder();
|
||||||
|
|||||||
Reference in New Issue
Block a user