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