Loading apct-tests/perftests/core/Android.bp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,9 @@ android_test { "apct-perftests-resources-manager-apps", "apct-perftests-resources-manager-apps", "apct-perftests-utils", "apct-perftests-utils", "collector-device-lib", "collector-device-lib", "compatibility-device-util-axt", "junit", "junit-params", "core-tests-support", "core-tests-support", "guava", "guava", ], ], Loading apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java +15 −15 Original line number Original line Diff line number Diff line Loading @@ -20,18 +20,19 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.lang.reflect.Array; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collection; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class DeepArrayOpsPerfTest { public class DeepArrayOpsPerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); Loading @@ -39,19 +40,14 @@ public class DeepArrayOpsPerfTest { private Object[] mArray; private Object[] mArray; private Object[] mArray2; private Object[] mArray2; @Parameterized.Parameter(0) public static Collection<Object[]> getData() { public int mArrayLength; @Parameterized.Parameters(name = "mArrayLength({0})") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}}); return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}}); } } @Before public void setUp(int arrayLength) throws Exception { public void setUp() throws Exception { mArray = new Object[arrayLength * 14]; mArray = new Object[mArrayLength * 14]; mArray2 = new Object[arrayLength * 14]; mArray2 = new Object[mArrayLength * 14]; for (int i = 0; i < arrayLength; i += 14) { for (int i = 0; i < mArrayLength; i += 14) { mArray[i] = new IntWrapper(i); mArray[i] = new IntWrapper(i); mArray2[i] = new IntWrapper(i); mArray2[i] = new IntWrapper(i); Loading Loading @@ -99,7 +95,9 @@ public class DeepArrayOpsPerfTest { } } @Test @Test public void deepHashCode() { @Parameters(method = "getData") public void deepHashCode(int arrayLength) throws Exception { setUp(arrayLength); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { Arrays.deepHashCode(mArray); Arrays.deepHashCode(mArray); Loading @@ -107,7 +105,9 @@ public class DeepArrayOpsPerfTest { } } @Test @Test public void deepEquals() { @Parameters(method = "getData") public void deepEquals(int arrayLength) throws Exception { setUp(arrayLength); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { Arrays.deepEquals(mArray, mArray2); Arrays.deepEquals(mArray, mArray2); Loading apct-tests/perftests/core/src/android/libcore/SystemArrayCopyPerfTest.java +21 −16 Original line number Original line Diff line number Diff line Loading @@ -20,22 +20,22 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collection; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class SystemArrayCopyPerfTest { public class SystemArrayCopyPerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Parameters(name = "arrayLength={0}") public static Collection<Object[]> getData() { public static Collection<Object[]> data() { return Arrays.asList( return Arrays.asList( new Object[][] { new Object[][] { {2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096}, {2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096}, 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. // Provides benchmarking for different types of arrays using the arraycopy function. @Test @Test public void timeSystemCharArrayCopy() { @Parameters(method = "getData") public void timeSystemCharArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; char[] src = new char[len]; char[] src = new char[len]; char[] dst = new char[len]; char[] dst = new char[len]; Loading @@ -59,7 +57,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemByteArrayCopy() { @Parameters(method = "getData") public void timeSystemByteArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; byte[] src = new byte[len]; byte[] src = new byte[len]; byte[] dst = new byte[len]; byte[] dst = new byte[len]; Loading @@ -70,7 +69,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemShortArrayCopy() { @Parameters(method = "getData") public void timeSystemShortArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; short[] src = new short[len]; short[] src = new short[len]; short[] dst = new short[len]; short[] dst = new short[len]; Loading @@ -81,7 +81,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemIntArrayCopy() { @Parameters(method = "getData") public void timeSystemIntArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; int[] src = new int[len]; int[] src = new int[len]; int[] dst = new int[len]; int[] dst = new int[len]; Loading @@ -92,7 +93,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemLongArrayCopy() { @Parameters(method = "getData") public void timeSystemLongArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; long[] src = new long[len]; long[] src = new long[len]; long[] dst = new long[len]; long[] dst = new long[len]; Loading @@ -103,7 +105,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemFloatArrayCopy() { @Parameters(method = "getData") public void timeSystemFloatArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; float[] src = new float[len]; float[] src = new float[len]; float[] dst = new float[len]; float[] dst = new float[len]; Loading @@ -114,7 +117,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemDoubleArrayCopy() { @Parameters(method = "getData") public void timeSystemDoubleArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; double[] src = new double[len]; double[] src = new double[len]; double[] dst = new double[len]; double[] dst = new double[len]; Loading @@ -125,7 +129,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemBooleanArrayCopy() { @Parameters(method = "getData") public void timeSystemBooleanArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; boolean[] src = new boolean[len]; boolean[] src = new boolean[len]; boolean[] dst = new boolean[len]; boolean[] dst = new boolean[len]; Loading apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java +23 −30 Original line number Original line Diff line number Diff line Loading @@ -20,42 +20,32 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer; import java.io.CharArrayWriter; import java.io.CharArrayWriter; import java.lang.reflect.Constructor; import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.Collection; import java.util.Random; import java.util.Random; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class XmlSerializePerfTest { public class XmlSerializePerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Parameters(name = "mDatasetAsString({0}), mSeed({1})") private Object[] getParams() { public static Collection<Object[]> data() { return new Object[][] { return Arrays.asList( new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 854328}, new Object[][] { new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 854328}, {"0.99 0.7 0.7 0.7 0.7 0.7", 854328}, new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 312547}, {"0.999 0.3 0.3 0.95 0.9 0.9", 854328}, new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 312547} {"0.99 0.7 0.7 0.7 0.7 0.7", 312547}, }; {"0.999 0.3 0.3 0.95 0.9 0.9", 312547} }); } } @Parameterized.Parameter(0) public String mDatasetAsString; @Parameterized.Parameter(1) public int mSeed; double[] mDataset; double[] mDataset; private Constructor<? extends XmlSerializer> mKxmlConstructor; private Constructor<? extends XmlSerializer> mKxmlConstructor; private Constructor<? extends XmlSerializer> mFastConstructor; private Constructor<? extends XmlSerializer> mFastConstructor; Loading Loading @@ -100,8 +90,7 @@ public class XmlSerializePerfTest { } } @SuppressWarnings("unchecked") @SuppressWarnings("unchecked") @Before public void setUp(String datasetAsString) throws Exception { public void setUp() throws Exception { mKxmlConstructor = mKxmlConstructor = (Constructor) (Constructor) Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor(); Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor(); Loading @@ -109,28 +98,32 @@ public class XmlSerializePerfTest { (Constructor) (Constructor) Class.forName("com.android.internal.util.FastXmlSerializer") Class.forName("com.android.internal.util.FastXmlSerializer") .getConstructor(); .getConstructor(); String[] splitStrings = mDatasetAsString.split(" "); String[] splitStrings = datasetAsString.split(" "); mDataset = new double[splitStrings.length]; mDataset = new double[splitStrings.length]; for (int i = 0; i < splitStrings.length; i++) { for (int i = 0; i < splitStrings.length; i++) { mDataset[i] = Double.parseDouble(splitStrings[i]); mDataset[i] = Double.parseDouble(splitStrings[i]); } } } } private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor) private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor, int seed) throws Exception { throws Exception { BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { serializeRandomXml(ctor, mSeed); serializeRandomXml(ctor, seed); } } } } @Test @Test public void timeKxml() throws Exception { @Parameters(method = "getParams") internalTimeSerializer(mKxmlConstructor); public void timeKxml(String datasetAsString, int seed) throws Exception { setUp(datasetAsString); internalTimeSerializer(mKxmlConstructor, seed); } } @Test @Test public void timeFast() throws Exception { @Parameters(method = "getParams") internalTimeSerializer(mFastConstructor); public void timeFast(String datasetAsString, int seed) throws Exception { setUp(datasetAsString); internalTimeSerializer(mFastConstructor, seed); } } } } apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java +9 −12 Original line number Original line Diff line number Diff line Loading @@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import java.io.File; import java.io.File; import java.io.FileOutputStream; import java.io.FileOutputStream; Loading @@ -38,23 +38,18 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class ZipFilePerfTest { public class ZipFilePerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); private File mFile; private File mFile; @Parameters(name = "numEntries={0}") public static Collection<Object[]> getData() { public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{128}, {1024}, {8192}}); return Arrays.asList(new Object[][] {{128}, {1024}, {8192}}); } } @Parameterized.Parameter(0) public void setUp(int numEntries) throws Exception { public int numEntries; @Before public void setUp() throws Exception { mFile = File.createTempFile(getClass().getName(), ".zip"); mFile = File.createTempFile(getClass().getName(), ".zip"); mFile.deleteOnExit(); mFile.deleteOnExit(); writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0); writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0); Loading @@ -66,7 +61,9 @@ public class ZipFilePerfTest { } } @Test @Test public void timeZipFileOpen() throws Exception { @Parameters(method = "getData") public void timeZipFileOpen(int numEntries) throws Exception { setUp(numEntries); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { ZipFile zf = new ZipFile(mFile); ZipFile zf = new ZipFile(mFile); Loading Loading
apct-tests/perftests/core/Android.bp +3 −0 Original line number Original line Diff line number Diff line Loading @@ -43,6 +43,9 @@ android_test { "apct-perftests-resources-manager-apps", "apct-perftests-resources-manager-apps", "apct-perftests-utils", "apct-perftests-utils", "collector-device-lib", "collector-device-lib", "compatibility-device-util-axt", "junit", "junit-params", "core-tests-support", "core-tests-support", "guava", "guava", ], ], Loading
apct-tests/perftests/core/src/android/libcore/DeepArrayOpsPerfTest.java +15 −15 Original line number Original line Diff line number Diff line Loading @@ -20,18 +20,19 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.lang.reflect.Array; import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collection; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class DeepArrayOpsPerfTest { public class DeepArrayOpsPerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); Loading @@ -39,19 +40,14 @@ public class DeepArrayOpsPerfTest { private Object[] mArray; private Object[] mArray; private Object[] mArray2; private Object[] mArray2; @Parameterized.Parameter(0) public static Collection<Object[]> getData() { public int mArrayLength; @Parameterized.Parameters(name = "mArrayLength({0})") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}}); return Arrays.asList(new Object[][] {{1}, {4}, {16}, {32}, {2048}}); } } @Before public void setUp(int arrayLength) throws Exception { public void setUp() throws Exception { mArray = new Object[arrayLength * 14]; mArray = new Object[mArrayLength * 14]; mArray2 = new Object[arrayLength * 14]; mArray2 = new Object[mArrayLength * 14]; for (int i = 0; i < arrayLength; i += 14) { for (int i = 0; i < mArrayLength; i += 14) { mArray[i] = new IntWrapper(i); mArray[i] = new IntWrapper(i); mArray2[i] = new IntWrapper(i); mArray2[i] = new IntWrapper(i); Loading Loading @@ -99,7 +95,9 @@ public class DeepArrayOpsPerfTest { } } @Test @Test public void deepHashCode() { @Parameters(method = "getData") public void deepHashCode(int arrayLength) throws Exception { setUp(arrayLength); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { Arrays.deepHashCode(mArray); Arrays.deepHashCode(mArray); Loading @@ -107,7 +105,9 @@ public class DeepArrayOpsPerfTest { } } @Test @Test public void deepEquals() { @Parameters(method = "getData") public void deepEquals(int arrayLength) throws Exception { setUp(arrayLength); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { Arrays.deepEquals(mArray, mArray2); Arrays.deepEquals(mArray, mArray2); Loading
apct-tests/perftests/core/src/android/libcore/SystemArrayCopyPerfTest.java +21 −16 Original line number Original line Diff line number Diff line Loading @@ -20,22 +20,22 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collection; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class SystemArrayCopyPerfTest { public class SystemArrayCopyPerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Parameters(name = "arrayLength={0}") public static Collection<Object[]> getData() { public static Collection<Object[]> data() { return Arrays.asList( return Arrays.asList( new Object[][] { new Object[][] { {2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096}, {2}, {4}, {8}, {16}, {32}, {64}, {128}, {256}, {512}, {1024}, {2048}, {4096}, 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. // Provides benchmarking for different types of arrays using the arraycopy function. @Test @Test public void timeSystemCharArrayCopy() { @Parameters(method = "getData") public void timeSystemCharArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; char[] src = new char[len]; char[] src = new char[len]; char[] dst = new char[len]; char[] dst = new char[len]; Loading @@ -59,7 +57,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemByteArrayCopy() { @Parameters(method = "getData") public void timeSystemByteArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; byte[] src = new byte[len]; byte[] src = new byte[len]; byte[] dst = new byte[len]; byte[] dst = new byte[len]; Loading @@ -70,7 +69,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemShortArrayCopy() { @Parameters(method = "getData") public void timeSystemShortArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; short[] src = new short[len]; short[] src = new short[len]; short[] dst = new short[len]; short[] dst = new short[len]; Loading @@ -81,7 +81,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemIntArrayCopy() { @Parameters(method = "getData") public void timeSystemIntArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; int[] src = new int[len]; int[] src = new int[len]; int[] dst = new int[len]; int[] dst = new int[len]; Loading @@ -92,7 +93,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemLongArrayCopy() { @Parameters(method = "getData") public void timeSystemLongArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; long[] src = new long[len]; long[] src = new long[len]; long[] dst = new long[len]; long[] dst = new long[len]; Loading @@ -103,7 +105,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemFloatArrayCopy() { @Parameters(method = "getData") public void timeSystemFloatArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; float[] src = new float[len]; float[] src = new float[len]; float[] dst = new float[len]; float[] dst = new float[len]; Loading @@ -114,7 +117,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemDoubleArrayCopy() { @Parameters(method = "getData") public void timeSystemDoubleArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; double[] src = new double[len]; double[] src = new double[len]; double[] dst = new double[len]; double[] dst = new double[len]; Loading @@ -125,7 +129,8 @@ public class SystemArrayCopyPerfTest { } } @Test @Test public void timeSystemBooleanArrayCopy() { @Parameters(method = "getData") public void timeSystemBooleanArrayCopy(int arrayLength) { final int len = arrayLength; final int len = arrayLength; boolean[] src = new boolean[len]; boolean[] src = new boolean[len]; boolean[] dst = new boolean[len]; boolean[] dst = new boolean[len]; Loading
apct-tests/perftests/core/src/android/libcore/XmlSerializePerfTest.java +23 −30 Original line number Original line Diff line number Diff line Loading @@ -20,42 +20,32 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer; import java.io.CharArrayWriter; import java.io.CharArrayWriter; import java.lang.reflect.Constructor; import java.lang.reflect.Constructor; import java.util.Arrays; import java.util.Collection; import java.util.Random; import java.util.Random; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class XmlSerializePerfTest { public class XmlSerializePerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Parameters(name = "mDatasetAsString({0}), mSeed({1})") private Object[] getParams() { public static Collection<Object[]> data() { return new Object[][] { return Arrays.asList( new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 854328}, new Object[][] { new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 854328}, {"0.99 0.7 0.7 0.7 0.7 0.7", 854328}, new Object[] {"0.99 0.7 0.7 0.7 0.7 0.7", 312547}, {"0.999 0.3 0.3 0.95 0.9 0.9", 854328}, new Object[] {"0.999 0.3 0.3 0.95 0.9 0.9", 312547} {"0.99 0.7 0.7 0.7 0.7 0.7", 312547}, }; {"0.999 0.3 0.3 0.95 0.9 0.9", 312547} }); } } @Parameterized.Parameter(0) public String mDatasetAsString; @Parameterized.Parameter(1) public int mSeed; double[] mDataset; double[] mDataset; private Constructor<? extends XmlSerializer> mKxmlConstructor; private Constructor<? extends XmlSerializer> mKxmlConstructor; private Constructor<? extends XmlSerializer> mFastConstructor; private Constructor<? extends XmlSerializer> mFastConstructor; Loading Loading @@ -100,8 +90,7 @@ public class XmlSerializePerfTest { } } @SuppressWarnings("unchecked") @SuppressWarnings("unchecked") @Before public void setUp(String datasetAsString) throws Exception { public void setUp() throws Exception { mKxmlConstructor = mKxmlConstructor = (Constructor) (Constructor) Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor(); Class.forName("com.android.org.kxml2.io.KXmlSerializer").getConstructor(); Loading @@ -109,28 +98,32 @@ public class XmlSerializePerfTest { (Constructor) (Constructor) Class.forName("com.android.internal.util.FastXmlSerializer") Class.forName("com.android.internal.util.FastXmlSerializer") .getConstructor(); .getConstructor(); String[] splitStrings = mDatasetAsString.split(" "); String[] splitStrings = datasetAsString.split(" "); mDataset = new double[splitStrings.length]; mDataset = new double[splitStrings.length]; for (int i = 0; i < splitStrings.length; i++) { for (int i = 0; i < splitStrings.length; i++) { mDataset[i] = Double.parseDouble(splitStrings[i]); mDataset[i] = Double.parseDouble(splitStrings[i]); } } } } private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor) private void internalTimeSerializer(Constructor<? extends XmlSerializer> ctor, int seed) throws Exception { throws Exception { BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { serializeRandomXml(ctor, mSeed); serializeRandomXml(ctor, seed); } } } } @Test @Test public void timeKxml() throws Exception { @Parameters(method = "getParams") internalTimeSerializer(mKxmlConstructor); public void timeKxml(String datasetAsString, int seed) throws Exception { setUp(datasetAsString); internalTimeSerializer(mKxmlConstructor, seed); } } @Test @Test public void timeFast() throws Exception { @Parameters(method = "getParams") internalTimeSerializer(mFastConstructor); public void timeFast(String datasetAsString, int seed) throws Exception { setUp(datasetAsString); internalTimeSerializer(mFastConstructor, seed); } } } }
apct-tests/perftests/core/src/android/libcore/ZipFilePerfTest.java +9 −12 Original line number Original line Diff line number Diff line Loading @@ -20,12 +20,12 @@ import android.perftests.utils.BenchmarkState; import android.perftests.utils.PerfStatusReporter; import android.perftests.utils.PerfStatusReporter; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.LargeTest; import org.junit.Before; import junitparams.JUnitParamsRunner; import junitparams.Parameters; import org.junit.Rule; import org.junit.Rule; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; import java.io.File; import java.io.File; import java.io.FileOutputStream; import java.io.FileOutputStream; Loading @@ -38,23 +38,18 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream; @RunWith(Parameterized.class) @RunWith(JUnitParamsRunner.class) @LargeTest @LargeTest public class ZipFilePerfTest { public class ZipFilePerfTest { @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); private File mFile; private File mFile; @Parameters(name = "numEntries={0}") public static Collection<Object[]> getData() { public static Collection<Object[]> data() { return Arrays.asList(new Object[][] {{128}, {1024}, {8192}}); return Arrays.asList(new Object[][] {{128}, {1024}, {8192}}); } } @Parameterized.Parameter(0) public void setUp(int numEntries) throws Exception { public int numEntries; @Before public void setUp() throws Exception { mFile = File.createTempFile(getClass().getName(), ".zip"); mFile = File.createTempFile(getClass().getName(), ".zip"); mFile.deleteOnExit(); mFile.deleteOnExit(); writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0); writeEntries(new ZipOutputStream(new FileOutputStream(mFile)), numEntries, 0); Loading @@ -66,7 +61,9 @@ public class ZipFilePerfTest { } } @Test @Test public void timeZipFileOpen() throws Exception { @Parameters(method = "getData") public void timeZipFileOpen(int numEntries) throws Exception { setUp(numEntries); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); while (state.keepRunning()) { while (state.keepRunning()) { ZipFile zf = new ZipFile(mFile); ZipFile zf = new ZipFile(mFile); Loading