Loading apct-tests/perftests/core/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -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", ], Loading apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java +15 −15 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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); Loading Loading @@ -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); Loading @@ -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); Loading apct-tests/perftests/core/src/android/libcore/SystemArrayCopyPerfTest.java +21 −16 Original line number Diff line number Diff line Loading @@ -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}, Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java +23 −30 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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); } } apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java +9 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading Loading
apct-tests/perftests/core/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -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", ], Loading
apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java +15 −15 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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); Loading Loading @@ -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); Loading @@ -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); Loading
apct-tests/perftests/core/src/android/libcore/SystemArrayCopyPerfTest.java +21 −16 Original line number Diff line number Diff line Loading @@ -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}, Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading @@ -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]; Loading
apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java +23 −30 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); Loading @@ -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); } }
apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java +9 −12 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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); Loading