From bd1c5da28dab9c3fb7e19bdadb22d7ad960fa3c3 Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Tue, 21 Dec 2010 08:21:48 -0800 Subject: Remove unused performance tests. Change-Id: I5a252e314831716f99ce5fbb32d983c7473ee787 --- core/tests/coretests/AndroidManifest.xml | 87 +- .../android/test/InstrumentationTestRunner.java | 7 - .../src/android/test/PerformanceTestBase.java | 33 - .../android/test/suitebuilder/TestPredicates.java | 3 - .../test/suitebuilder/TestSuiteBuilder.java | 11 +- .../test/suitebuilder/UnitTestSuiteBuilder.java | 3 +- .../android/core/AndroidPerformanceTests.java | 35 - .../android/core/ArrayListPerformanceTest.java | 327 ------ tests/CoreTests/android/core/HashMapPerfTest.java | 93 -- .../android/core/HashMapPerformanceTest.java | 185 --- tests/CoreTests/android/core/HashSetTest.java | 207 ---- tests/CoreTests/android/core/HashtableTest.java | 357 ------ .../android/core/JavaPerformanceTests.java | 37 - tests/CoreTests/android/core/LinkedListTest.java | 529 --------- .../android/core/MathPerformanceTest.java | 380 ------ tests/CoreTests/android/core/PerformanceTests.java | 1224 -------------------- .../android/core/TreeMapPerformanceTest.java | 281 ----- tests/CoreTests/android/core/TreeSetTest.java | 349 ------ tests/CoreTests/android/core/VectorTest.java | 555 --------- 19 files changed, 46 insertions(+), 4657 deletions(-) delete mode 100644 test-runner/src/android/test/PerformanceTestBase.java delete mode 100644 tests/CoreTests/android/core/AndroidPerformanceTests.java delete mode 100644 tests/CoreTests/android/core/ArrayListPerformanceTest.java delete mode 100644 tests/CoreTests/android/core/HashMapPerfTest.java delete mode 100644 tests/CoreTests/android/core/HashMapPerformanceTest.java delete mode 100644 tests/CoreTests/android/core/HashSetTest.java delete mode 100644 tests/CoreTests/android/core/HashtableTest.java delete mode 100644 tests/CoreTests/android/core/JavaPerformanceTests.java delete mode 100644 tests/CoreTests/android/core/LinkedListTest.java delete mode 100644 tests/CoreTests/android/core/MathPerformanceTest.java delete mode 100644 tests/CoreTests/android/core/PerformanceTests.java delete mode 100644 tests/CoreTests/android/core/TreeMapPerformanceTest.java delete mode 100644 tests/CoreTests/android/core/TreeSetTest.java delete mode 100644 tests/CoreTests/android/core/VectorTest.java diff --git a/core/tests/coretests/AndroidManifest.xml b/core/tests/coretests/AndroidManifest.xml index f2857fa..72120a8 100644 --- a/core/tests/coretests/AndroidManifest.xml +++ b/core/tests/coretests/AndroidManifest.xml @@ -4,9 +4,9 @@ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -117,7 +117,7 @@ - + @@ -145,28 +145,28 @@ - + - + - + - + @@ -180,7 +180,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -285,7 +285,7 @@ - + @@ -483,7 +483,7 @@ - + @@ -518,7 +518,7 @@ - + @@ -532,21 +532,21 @@ - + - + - + @@ -568,19 +568,19 @@ - + - + - + @@ -615,21 +615,21 @@ - + - + - + @@ -643,14 +643,14 @@ - + - + @@ -665,7 +665,7 @@ - + @@ -686,14 +686,14 @@ - + - + @@ -721,21 +721,21 @@ - + - + - + @@ -770,30 +770,30 @@ - + - + - + - + - + @@ -884,21 +884,21 @@ - + - + - + @@ -1012,7 +1012,7 @@ - + @@ -1037,9 +1037,9 @@ - + - + @@ -1052,13 +1052,6 @@ - - - - - - - testSizePredicate = null; Predicate testAnnotationPredicate = null; Predicate testNotAnnotationPredicate = null; - boolean includePerformance = false; String testClassesArg = null; boolean logOnly = false; @@ -323,7 +320,6 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu testNotAnnotationPredicate = getNotAnnotationPredicate( arguments.getString(ARGUMENT_NOT_ANNOTATION)); - includePerformance = getBooleanArgument(arguments, ARGUMENT_INCLUDE_PERF); logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY); mCoverage = getBooleanArgument(arguments, "coverage"); mCoverageFilePath = arguments.getString("coverageFile"); @@ -348,9 +344,6 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu if (testNotAnnotationPredicate != null) { testSuiteBuilder.addRequirements(testNotAnnotationPredicate); } - if (!includePerformance) { - testSuiteBuilder.addRequirements(REJECT_PERFORMANCE); - } if (testClassesArg == null) { if (mPackageOfTests != null) { diff --git a/test-runner/src/android/test/PerformanceTestBase.java b/test-runner/src/android/test/PerformanceTestBase.java deleted file mode 100644 index 4a0a589..0000000 --- a/test-runner/src/android/test/PerformanceTestBase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.test; - -import junit.framework.TestCase; - -/** - * {@hide} Not needed for SDK. - */ -public class PerformanceTestBase extends TestCase implements PerformanceTestCase { - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - return 0; - } - - public boolean isPerformanceOnly() { - return true; - } -} diff --git a/test-runner/src/android/test/suitebuilder/TestPredicates.java b/test-runner/src/android/test/suitebuilder/TestPredicates.java index d814e0b..47aca55 100644 --- a/test-runner/src/android/test/suitebuilder/TestPredicates.java +++ b/test-runner/src/android/test/suitebuilder/TestPredicates.java @@ -17,7 +17,6 @@ package android.test.suitebuilder; import android.test.InstrumentationTestCase; -import android.test.PerformanceTestBase; import android.test.suitebuilder.annotation.HasAnnotation; import android.test.suitebuilder.annotation.Suppress; import android.test.suitebuilder.annotation.LargeTest; @@ -43,7 +42,5 @@ public class TestPredicates { public static final Predicate SELECT_LARGE = new HasAnnotation(LargeTest.class); public static final Predicate REJECT_SUPPRESSED = Predicates.not(new HasAnnotation(Suppress.class)); - public static final Predicate REJECT_PERFORMANCE = - Predicates.not(new AssignableFrom(PerformanceTestBase.class)); } diff --git a/test-runner/src/android/test/suitebuilder/TestSuiteBuilder.java b/test-runner/src/android/test/suitebuilder/TestSuiteBuilder.java index 428905e..28f7216 100644 --- a/test-runner/src/android/test/suitebuilder/TestSuiteBuilder.java +++ b/test-runner/src/android/test/suitebuilder/TestSuiteBuilder.java @@ -24,7 +24,6 @@ import com.android.internal.util.Predicate; import com.google.android.collect.Lists; import static android.test.suitebuilder.TestGrouping.SORT_BY_FULLY_QUALIFIED_NAME; import static android.test.suitebuilder.TestPredicates.REJECT_SUPPRESSED; -import static android.test.suitebuilder.TestPredicates.REJECT_PERFORMANCE; import junit.framework.Test; import junit.framework.TestCase; @@ -71,9 +70,9 @@ public class TestSuiteBuilder { this.testCases = Lists.newArrayList(); addRequirements(REJECT_SUPPRESSED); } - + /** @hide pending API Council approval */ - public TestSuiteBuilder addTestClassByName(String testClassName, String testMethodName, + public TestSuiteBuilder addTestClassByName(String testClassName, String testMethodName, Context context) { AndroidTestRunner atr = new AndroidTestRunner(); @@ -83,7 +82,7 @@ public class TestSuiteBuilder { this.testCases.addAll(atr.getTestCases()); return this; } - + /** @hide pending API Council approval */ public TestSuiteBuilder addTestSuite(TestSuite testSuite) { for (TestCase testCase : (List) TestCaseUtil.getTests(testSuite, true)) { @@ -242,7 +241,7 @@ public class TestSuiteBuilder { /** * @return the test package that represents the packages that were included for our test suite. - * + * * {@hide} Not needed for 1.0 SDK. */ protected TestGrouping getTestGrouping() { @@ -262,7 +261,7 @@ public class TestSuiteBuilder { addSuiteIfNecessary(testMethod.getEnclosingClassname()); suiteForCurrentClass.addTest(testMethod.createTest()); } - + private void addTest(Test test) { addSuiteIfNecessary(test.getClass().getName()); suiteForCurrentClass.addTest(test); diff --git a/test-runner/src/android/test/suitebuilder/UnitTestSuiteBuilder.java b/test-runner/src/android/test/suitebuilder/UnitTestSuiteBuilder.java index 8cf4c86..a746b35 100644 --- a/test-runner/src/android/test/suitebuilder/UnitTestSuiteBuilder.java +++ b/test-runner/src/android/test/suitebuilder/UnitTestSuiteBuilder.java @@ -18,7 +18,7 @@ package android.test.suitebuilder; /** * A suite builder that finds unit tests. - * + * * {@hide} Not needed for 1.0 SDK. */ public class UnitTestSuiteBuilder extends TestSuiteBuilder { @@ -31,6 +31,5 @@ public class UnitTestSuiteBuilder extends TestSuiteBuilder { public UnitTestSuiteBuilder(String name, ClassLoader classLoader) { super(name, classLoader); addRequirements(TestPredicates.REJECT_INSTRUMENTATION); - addRequirements(TestPredicates.REJECT_PERFORMANCE); } } diff --git a/tests/CoreTests/android/core/AndroidPerformanceTests.java b/tests/CoreTests/android/core/AndroidPerformanceTests.java deleted file mode 100644 index e604d59..0000000 --- a/tests/CoreTests/android/core/AndroidPerformanceTests.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.TestListActivity; - -public class AndroidPerformanceTests extends TestListActivity { - @Override - public String getTestSuite() { - return "com.android.unit_tests.AndroidPerformanceTests$Suite"; - } - - public static class Suite { - public static String[] children() { - return new String[] { - JavaPerformanceTests.class.getName(), - PerformanceTests.class.getName(), - }; - } - } -} diff --git a/tests/CoreTests/android/core/ArrayListPerformanceTest.java b/tests/CoreTests/android/core/ArrayListPerformanceTest.java deleted file mode 100644 index 6130e83..0000000 --- a/tests/CoreTests/android/core/ArrayListPerformanceTest.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import java.util.ArrayList; -import android.test.PerformanceTestBase; - -public class ArrayListPerformanceTest extends PerformanceTestBase { - - private ArrayList mList; - - @Override - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - - mList = new ArrayList(); - mList.add(0); - mList.add(1); - mList.add(2); - mList.add(3); - mList.add(4); - mList.add(5); - mList.add(6); - mList.add(7); - mList.add(8); - mList.add(9); - } - - public void testArrayListAdd() { - int i = 0; - for (; i < 10; i++) { - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - mList.add(i); - } - } - - public void testArrayListAdd1() { - int i = 0; - for (; i < 10; i++) { - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - mList.add(7, i); - } - } - - public void testArrayListToArray() { - Object rArray; - int i = 0; - for (; i < 100; i++) { - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - rArray = mList.toArray(); - } - } - - public void testArrayListSize() { - int i = 0, len; - for (; i < 100; i++) { - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - len = mList.size(); - } - } - - public void testArrayListGet() { - int i = 0, value; - int len = mList.size(); - for (; i < len; i++) { - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - value = mList.get(i); - } - } - - public void testArrayListContains() { - boolean flag; - int i = 0; - - for (; i < 100; i++) { - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - flag = mList.contains(i); - - } - } - - public void testArrayListToArray1() { - Integer[] rArray = new Integer[10]; - - Integer[] mArray; - int i = 0; - for (; i < 100; i++) { - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - mArray = mList.toArray(rArray); - } - } - - public void testArrayListSet() { - int i = 0; - for (; i < 10; i++) { - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - mList.set(5, 0); - } - } - - public void testArrayListIndexOf() { - int i = 0, index; - - for (; i < 100; i++) { - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - index = mList.indexOf(0); - } - } - - public void testArrayListLastIndexOf() { - int i = 0, index; - - for (; i < 100; i++) { - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - index = mList.lastIndexOf(0); - } - } - - @SuppressWarnings("unchecked") - public void testArrayListRemove() { - ArrayList aList; - aList = new ArrayList(); - for (int j = 0; j < 10000; j++) { - aList.add(0); - } - - int i = 0, index; - - for (; i < 10; i++) { - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - index = aList.remove(0); - - - } - } - - @SuppressWarnings("unchecked") - public void testArrayListAddAll() { - ArrayList aList = new ArrayList(); - - int i = 0; - boolean b; - for (; i < 10; i++) { - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - b = aList.addAll(mList); - - } - } - - @SuppressWarnings("unchecked") - public void testArrayListRemove1() { - ArrayList aList; - String s; - - aList = new ArrayList(); - for (int j = 0; j < 100; j++) { - aList.add("a"); - aList.add("b"); - } - s = new String("a"); - - int i = 0; - boolean b; - for (; i < 10; i++) { - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - b = aList.remove(s); - } - } - - @SuppressWarnings("unchecked") - public void testArrayListAddAll1() { - ArrayList aList = new ArrayList(); - - int i = 0; - boolean b; - - for (; i < 10; i++) { - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - b = aList.addAll(0, mList); - } - } - - public void testArrayListClone() { - Object rObj; - int i = 0; - - for (; i < 100; i++) { - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - rObj = mList.clone(); - } - } -} diff --git a/tests/CoreTests/android/core/HashMapPerfTest.java b/tests/CoreTests/android/core/HashMapPerfTest.java deleted file mode 100644 index 8475222..0000000 --- a/tests/CoreTests/android/core/HashMapPerfTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.os.SystemClock; -import android.test.suitebuilder.annotation.LargeTest; -import junit.framework.TestCase; - -import java.util.HashMap; -import java.util.Random; - -/** - * Tests basic functionality of HashMaps and prints the time needed to System.out - */ -public class HashMapPerfTest extends TestCase { - - private static final Random sRandom = new Random(1); - - class StringThing { - - String mId; - - public StringThing() { - int len = sRandom.nextInt(20) + 1; - char[] chars = new char[len]; - chars[0] = 't'; - for (int i = 1; i < len; i++) { - chars[i] = (char) ('q' + sRandom.nextInt(4)); - } - mId = new String(chars, 0, len); - } - - public String getId() { - return mId; - } - } - - private static final int NUM_ELTS = 1000; - private static final int ITERS = 100; - - String[] keyCopies = new String[NUM_ELTS]; - - private static final boolean lookupByOriginals = false; - - @LargeTest - public void testHashMapPerformance() throws Exception { - StringThing[] st = new StringThing[NUM_ELTS]; - for (int i = 0; i < NUM_ELTS; i++) { - st[i] = new StringThing(); - keyCopies[i] = st[i].getId(); - } - - // android.os.Debug.startMethodTracing(); - long start = SystemClock.uptimeMillis(); - for (int i = 0; i < ITERS; i++) { - HashMap map = new HashMap(); - for (int j = 0; j < NUM_ELTS; j++) { - StringThing s = st[i]; - map.put(s.getId(), s); - } - for (int j = 0; j < NUM_ELTS; j++) { - if (lookupByOriginals) { - StringThing s = st[i]; - map.get(s.getId()); - } else { - map.get(keyCopies[j]); - } - } - } - long finish = SystemClock.uptimeMillis(); - // android.os.Debug.stopMethodTracing(); - - // This should be an assertion instead - -// System.out.println("time (" + NUM_ELTS + -// ", elts, " + ITERS + -// " iters) = " + (finish - start)); - } -} diff --git a/tests/CoreTests/android/core/HashMapPerformanceTest.java b/tests/CoreTests/android/core/HashMapPerformanceTest.java deleted file mode 100644 index 82727bb..0000000 --- a/tests/CoreTests/android/core/HashMapPerformanceTest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Set; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -public class HashMapPerformanceTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public HashMap mMap; - public String[] mKeys; - - @Override - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - mMap = new HashMap(); - mKeys = new String[ITERATIONS]; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - mKeys[i] = Integer.toString(i, 16); - mMap.put(mKeys[i], i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testHashMapGet() { - int num; - for (int i = ITERATIONS - 1; i >= 0; i--) { - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - num = (Integer) mMap.get(mKeys[i]); - } - } - - public void testHashMapKeySet() { - Set keyset; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - keyset = mMap.keySet(); - } - } - - public void testHashMapEntrySet() { - Set keyset; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - keyset = mMap.entrySet(); - - - } - } - - public void testHashMapValues() { - Collection c; - for (int i = ITERATIONS - 1; i >= 0; i--) { - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - c = mMap.values(); - - - } - } - - public void testHashMapSize() { - int len; - for (int i = ITERATIONS - 1; i >= 0; i--) { - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - len = mMap.size(); - - - } - } - - public void testHashMapContainsValue() { - boolean flag; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - flag = mMap.containsValue(i); - - - } - } - - public void testHashMapRemove() { - for (int i = ITERATIONS - 1; i >= 0; i--) { - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - mMap.remove(mKeys[i]); - } - } - - - public void testHashMapClone() { - HashMap cMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - cMap = (HashMap) mMap.clone(); - } - } -} diff --git a/tests/CoreTests/android/core/HashSetTest.java b/tests/CoreTests/android/core/HashSetTest.java deleted file mode 100644 index 09a711f..0000000 --- a/tests/CoreTests/android/core/HashSetTest.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.HashSet; -import java.util.Iterator; - -/** - * Implements basic performance test functionality for HashSets - */ - -public class HashSetTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public static HashSet sSet; - - @Override - protected void setUp() throws Exception { - super.setUp(); - sSet = new HashSet(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - sSet.add(i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - /** - * - * Tests performance for the HashSet method Add(Object arg 0) - * - */ - - @SuppressWarnings("unchecked") - public void testHashSetAdd() { - HashSet set = new HashSet(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - } - - } - - /** - * - * Tests performance of HashSet method contains(Object arg 0) - * - */ - - public void testHashSetContains() { - Integer index = new Integer(500); - boolean flag; - HashSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - } - } - - /** - * - * Tests performance of HashSet method size() - * - */ - - public void testHashSetSize() { - int num; - HashSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - num = set.size(); - } - } - - /** - * - * Tests performance of the HashSet method -iterator() - * - */ - - public void testHashSetIterator() { - Iterator iterator; - HashSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - } - } - - /** - * - * Tests performance for the HashSet method Remove(Object arg 0) - * - */ - - @SuppressWarnings("unchecked") - public void testHashSetRemove() { - HashSet set = new HashSet(sSet); - for (int i = ITERATIONS - 1; i >= 0; i--) { - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - } - } - - /** - * - * Tests performance for the HashSet method isEmpty(Object arg 0) - * - */ - - public void testHashSetIsEmpty() { - HashSet set = sSet; - boolean flag; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - flag = set.isEmpty(); - } - } - - /** - * - * Tests performance for the HashSet method clone() - * - */ - - public void testHashSetClone() { - HashSet hSet = sSet; - Object set; - for (int i = ITERATIONS - 1; i > 0; i--) { - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - set = hSet.clone(); - } - } -} diff --git a/tests/CoreTests/android/core/HashtableTest.java b/tests/CoreTests/android/core/HashtableTest.java deleted file mode 100644 index 6160f57..0000000 --- a/tests/CoreTests/android/core/HashtableTest.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.Hashtable; -import java.util.Set; -import java.util.Enumeration; - -/** - * Implements basic performance test functionality for java.util.Hashtable - */ - -public class HashtableTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public Hashtable sTable; - public String[] sKeys; - - @Override - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - sTable = new Hashtable(); - sKeys = new String[ITERATIONS]; - for (int i = ITERATIONS - 1; i >= 0; i--) { - sKeys[i] = Integer.toString(i, 16); - sTable.put(sKeys[i], i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - @SuppressWarnings("unchecked") - public void testHashtablePut() { - Hashtable hTable = new Hashtable(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - hTable.put(i, i); - } - } - - public void testHashtableGet() { - int value; - String[] keys = sKeys; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - value = hTable.get(keys[i]); - } - } - - public void testHashtablekeyset() { - Set keyset; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - keyset = hTable.keySet(); - } - } - - /** - * - */ - - public void testHashtableEntrySet() { - Set keyset; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - keyset = hTable.entrySet(); - } - } - - public void testHashtableSize() { - int len; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - len = hTable.size(); - } - } - - public void testHashtableContainsValue() { - boolean flag; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - flag = hTable.containsValue(i); - } - } - - @SuppressWarnings("unchecked") - public void testHashtableRemove() { - Hashtable hTable = new Hashtable(sTable); - String[] keys = sKeys; - for (int i = ITERATIONS - 1; i >= 0; i--) { - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - hTable.remove(keys[i]); - } - } - - public void testHashtableContains() { - Hashtable hTable = sTable; - boolean flag; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - flag = hTable.contains(i); - } - } - - public void testHashtableContainsKey() { - Hashtable hTable = sTable; - boolean flag; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - flag = hTable.containsKey(i); - } - } - - public void testHashtableIsEmpty() { - Hashtable hTable = sTable; - boolean flag; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - flag = hTable.isEmpty(); - } - } - - public void testHashtableKeys() { - Hashtable hTable = sTable; - Enumeration keys; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - keys = hTable.keys(); - } - } - - public void testHashtableElements() { - Hashtable hTable = sTable; - Enumeration elements; - for (int i = ITERATIONS - 1; i >= 0; i--) { - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - elements = hTable.elements(); - } - } - - public void testHashtableHashCode() { - int index; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - index = hTable.hashCode(); - } - } - - public void testHashtableEquals() { - boolean flag; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - flag = hTable.equals(hTable); - } - } - - public void testHashtableToString() { - String str; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - str = hTable.toString(); - } - } - - @SuppressWarnings("unchecked") - public void testHashtablePutAll() { - Hashtable hTable = new Hashtable(); - Hashtable hTable1 = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - hTable.putAll(hTable1); - } - } - - /** - * - * clone() returns a Hashtable .. It should return Object as per the - * specification. - * - */ - - public void testHashtableClone() { - Hashtable hashTable; - Hashtable hTable = sTable; - for (int i = ITERATIONS - 1; i >= 0; i--) { - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - hashTable = (Hashtable) hTable.clone(); - } - } -} diff --git a/tests/CoreTests/android/core/JavaPerformanceTests.java b/tests/CoreTests/android/core/JavaPerformanceTests.java deleted file mode 100644 index 95075ea..0000000 --- a/tests/CoreTests/android/core/JavaPerformanceTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -/** - * - */ -public class JavaPerformanceTests { - - public static String[] children() { - return new String[] { - HashMapPerformanceTest.class.getName(), - ArrayListPerformanceTest.class.getName(), - TreeMapPerformanceTest.class.getName(), - TreeSetTest.class.getName(), - HashSetTest.class.getName(), - HashtableTest.class.getName(), - VectorTest.class.getName(), - LinkedListTest.class.getName(), - MathPerformanceTest.class.getName(), - }; - } -} diff --git a/tests/CoreTests/android/core/LinkedListTest.java b/tests/CoreTests/android/core/LinkedListTest.java deleted file mode 100644 index 8b237fd..0000000 --- a/tests/CoreTests/android/core/LinkedListTest.java +++ /dev/null @@ -1,529 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; -import java.util.LinkedList; -import java.util.ListIterator; - -/** - * This class contains performance tests for methods in java.util.LinkedList - * - */ -@SuppressWarnings("unchecked") -public class LinkedListTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - LinkedList mLinkedList; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mLinkedList = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - mLinkedList.add(i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testLinkedListAdd() { - LinkedList list = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - list.add(i); - } - } - - public void testLinkedListAdd1() { - LinkedList list = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - list.add(0, i); - } - } - - public void testLinkedListToArray() { - Object array; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - array = list.toArray(); - } - } - - public void testLinkedListSize() { - LinkedList list = mLinkedList; - int len; - for (int i = ITERATIONS - 1; i >= 0; i--) { - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - len = list.size(); - } - } - - public void testLinkedListGet() { - int element; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - element = list.get(i); - } - } - - public void testLinkedListContains() { - boolean flag; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - flag = list.contains(i); - } - } - - public void testLinkedListToArray1() { - Integer[] rArray = new Integer[100]; - Integer[] array; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - array = list.toArray(rArray); - } - } - - public void testLinkedListSet() { - LinkedList list = mLinkedList; - int value1 = 500, value2 = 0; - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - list.set(value1, value2); - } - } - - public void testLinkedListIndexOf() { - int index; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - index = list.indexOf(0); - - } - } - - public void testLinkedListLastIndexOf() { - int index; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - index = list.lastIndexOf(0); - } - } - - public void testLinkedListRemove() { - int index; - LinkedList list = new LinkedList(mLinkedList); - for (int i = 10; i > 0; i--) { - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - index = list.remove(); - } - } - - public void testLinkedListRemove1() { - int index; - LinkedList list = new LinkedList(mLinkedList); - for (int i = 10; i > 0; i--) { - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - index = list.remove(0); - } - } - - public void testLinkedListRemoveFirst() { - int index; - LinkedList list = new LinkedList(mLinkedList); - for (int i = 10; i > 0; i--) { - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - index = list.removeFirst(); - } - } - - public void testLinkedListRemoveLast() { - int index; - LinkedList list = new LinkedList(mLinkedList); - for (int i = 10; i > 0; i--) { - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - index = list.removeLast(); - } - } - - public void testLinkedListAddAll() { - LinkedList mList = mLinkedList; - boolean flag; - LinkedList list = new LinkedList(); - for (int i = 10; i > 0; i--) { - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - flag = list.addAll(mList); - } - } - - public void testLinkedListRemove2() { - LinkedList list; - String s = new String("a"); - list = new LinkedList(); - for (int j = 1000; j > 0; j--) { - list.add("a"); - list.add("b"); - } - boolean flag; - for (int i = 10; i > 0; i--) { - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - flag = list.remove(s); - } - } - - public void testLinkedListAddAll1() { - LinkedList mList = new LinkedList(); - int pos = 0; - boolean flag; - LinkedList list = mLinkedList; - for (int i = 0; i < 10; i++) { - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - flag = mList.addAll(pos, list); - } - } - - public void testLinkedListClone() { - Object rObj; - LinkedList list = mLinkedList; - for (int i = 100; i > 0; i--) { - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - rObj = list.clone(); - } - } - - public void testLinkedListHashcode() { - int element; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - element = list.hashCode(); - } - } - - public void testLinkedListElement() { - int element; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - element = list.element(); - } - } - - public void testLinkedListToString() { - String str; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - str = list.toString(); - } - } - - public void testLinkedListIsEmpty() { - boolean flag; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - flag = list.isEmpty(); - } - } - - public void testLinkedListOffer() { - LinkedList list = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - list.offer(i); - } - } - - public void testLinkedListPeek() { - int element; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - element = list.peek(); - } - } - - public void testLinkedListPoll() { - int element; - LinkedList list = new LinkedList(mLinkedList); - for (int i = 10; i > 0; i--) { - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - element = list.poll(); - } - } - - public void testLinkedListAddLast() { - LinkedList list = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - list.addLast(i); - } - } - - public void testLinkedListAddFirst() { - LinkedList list = new LinkedList(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - list.addFirst(i); - } - } - - public void testLinkedListIterator() { - ListIterator iterator; - LinkedList list = mLinkedList; - for (int i = ITERATIONS - 1; i >= 0; i--) { - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - iterator = list.listIterator(); - } - } -} diff --git a/tests/CoreTests/android/core/MathPerformanceTest.java b/tests/CoreTests/android/core/MathPerformanceTest.java deleted file mode 100644 index b1eb500..0000000 --- a/tests/CoreTests/android/core/MathPerformanceTest.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -/** - * - * Implements basic performance test functionality for java.lang.Math - * - */ - -public class MathPerformanceTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public static final double sDouble1 = -2450.50; - public static final double sDouble2 = -500; - public static final float sFloat = 300.50f; - public static final int sInt = 90; - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testDoubleAbs() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - result = Math.abs(sDouble1); - } - } - - public void testFloatAbs() { - float result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - result = Math.abs(sFloat); - } - } - - public void testMathSin() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - result = Math.sin(sDouble1); - } - } - - public void testMathCos() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - result = Math.cos(sDouble1); - } - } - - public void testMathTan() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - result = Math.tan(sDouble1); - } - } - - public void testMathASin() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - result = Math.asin(sDouble1); - } - } - - public void testMathACos() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - result = Math.acos(sDouble1); - } - } - - public void testMathATan() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - result = Math.atan(sDouble1); - } - } - - public void testMathLog() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - result = Math.log(sDouble1); - } - } - - public void testMathSqrt() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - result = Math.sqrt(sDouble1); - } - } - - public void testMathCeil() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - result = Math.ceil(sDouble1); - } - } - - public void testMathRound() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - result = Math.round(sDouble1); - } - } - - public void testMathFloor() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - result = Math.floor(sDouble1); - } - } - - public void testMathExp() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - result = Math.exp(sDouble1); - } - } - - /** - * - */ - - public void testMathPow() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - result = Math.pow(sDouble1, sDouble2); - } - } - - public void testMathMax() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - result = Math.max(sDouble1, sDouble2); - } - } - - public void testMathMin() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - result = Math.min(sDouble1, sDouble2); - } - } - - public void testMathRandom() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - result = Math.random(); - } - } - - public void testMathIEEERemainder() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - result = Math.IEEEremainder(sDouble1, sDouble2); - } - } - - public void testMathToDegrees() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - result = Math.toDegrees(sDouble1); - } - } - - public void testMathToRadians() { - double result; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - result = Math.toRadians(sDouble1); - } - } -} diff --git a/tests/CoreTests/android/core/PerformanceTests.java b/tests/CoreTests/android/core/PerformanceTests.java deleted file mode 100644 index faf46e6..0000000 --- a/tests/CoreTests/android/core/PerformanceTests.java +++ /dev/null @@ -1,1224 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import org.apache.harmony.dalvik.NativeTestTarget; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; - -import junit.framework.Assert; - -public class PerformanceTests { - public static String[] children() { - return new String[] { - //StringEquals2.class.getName(), - //StringEquals10.class.getName(), - //StringEquals20.class.getName(), - //StringEquals200.class.getName(), - //StringEquals200U.class.getName(), - //StringCompareTo10.class.getName(), - //StringCompareTo200.class.getName(), - StringLength.class.getName(), - StringCrawl.class.getName(), - Ackermann.class.getName(), - AddTest.class.getName(), -// AddMemberVariableTest.class.getName(), - ArrayListIterator.class.getName(), - BoundsCheckTest.class.getName(), -// EmptyClassBaseTest.class.getName(), - EmptyJniStaticMethod0.class.getName(), - EmptyJniStaticMethod6.class.getName(), - EmptyJniStaticMethod6L.class.getName(), - FibonacciFast.class.getName(), - FibonacciSlow.class.getName(), -// LoopTests.class.getName(), -// HashMapTest.class.getName(), -// InterfaceTests.class.getName(), - LocalVariableAccess.class.getName(), - MemeberVariableAccess.class.getName(), - NestedLoop.class.getName(), -// StringConcatenationTests.class.getName(), -// ArrayListBase.class.getName(), - SynchronizedGetAndSetInt.class.getName(), - - /* this will not work on JamVM -- lacks atomic ops */ - AtomicGetAndSetInt.class.getName(), - }; - } - - public static class SizeTest { - private int mSize; - - public SizeTest(int size) { - mSize = size; - } - - public int size() { - return mSize; - } - } - - public static class LocalVariableAccess extends PerformanceTestBase { - private static final int ITERATIONS = 100000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 20); - return 0; - } - - public void testRun() { - boolean variable = false; - boolean local = true; - for (int i = ITERATIONS - 1; i >= 0; i--) { - local = variable; - local = variable; - local = variable; - local = variable; - local = variable; // 5 - local = variable; - local = variable; - local = variable; - local = variable; - local = variable; // 10 - local = variable; - local = variable; - local = variable; - local = variable; - local = variable; // 15 - local = variable; - local = variable; - local = variable; - local = variable; - local = variable; // 20 - } - } - } - - /* This test is intentionally misspelled. Please do not rename it. Thanks! */ - public static class MemeberVariableAccess extends PerformanceTestBase { - private static final int ITERATIONS = 100000; - - public volatile boolean mMember = false; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 20); - return 0; - } - - public void testRun() { - boolean local = true; - for (int i = ITERATIONS - 1; i >= 0; i--) { - local = mMember; - local = mMember; - local = mMember; - local = mMember; - local = mMember; // 5 - local = mMember; - local = mMember; - local = mMember; - local = mMember; - local = mMember; // 10 - local = mMember; - local = mMember; - local = mMember; - local = mMember; - local = mMember; // 15 - local = mMember; - local = mMember; - local = mMember; - local = mMember; - local = mMember; // 20 - } - } - } - - public static class ArrayListIterator extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private ArrayList mList; - private String[] mKeys; - private Iterator mIterator; - - public void setUp() throws Exception { - super.setUp(); - mList = new ArrayList(); - mKeys = new String[ITERATIONS]; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - mKeys[i] = Integer.toString(i, 16); - mList.add(mKeys[i]); - } - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testRun() { - mIterator = mList.iterator(); - while (mIterator.hasNext()) { - mIterator.next(); - } - } - } - - public static class Ackermann extends PerformanceTestBase { - public static final int ITERATIONS = 100; - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testRun() { - for (int i = ITERATIONS - 1; i >= 0; i--) { - ackermann(3, 13); - } - } - - private int ackermann(int m, int n) { - if (m == 0) - return n + 1; - if (n == 0) - return ackermann(m - 1, 1); - return ackermann(m, n - 1); - } - } - - public static class FibonacciSlow extends PerformanceTestBase { - public void setUp() throws Exception { - super.setUp(); - Assert.assertEquals(0, fibonacci(0)); - Assert.assertEquals(1, fibonacci(1)); - Assert.assertEquals(1, fibonacci(2)); - Assert.assertEquals(2, fibonacci(3)); - Assert.assertEquals(6765, fibonacci(20)); - } - - public void tearDown() { - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - return 0; - } - - public void testRun() { - fibonacci(20); - } - - private long fibonacci(long n) { - if (n == 0) - return 0; - if (n == 1) - return 1; - return fibonacci(n - 2) + fibonacci(n - 1); - } - } - - public static class FibonacciFast extends PerformanceTestBase { - public void setUp() throws Exception { - super.setUp(); - Assert.assertEquals(0, fibonacci(0)); - Assert.assertEquals(1, fibonacci(1)); - Assert.assertEquals(1, fibonacci(2)); - Assert.assertEquals(2, fibonacci(3)); - Assert.assertEquals(6765, fibonacci(20)); - } - - public void tearDown() { - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - return 0; - } - - public void testRun() { - fibonacci(5000); - } - - private long fibonacci(long n) { - if (n == 0) - return 0; - if (n == 1) - return 1; - - int x = 0; - int y = 1; - for (int i = 0; i < n - 1; i++) { - y = y + x; - x = y - x; - } - - return y; - } - } - - public static class HashMapTest extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private HashMap mMap; - private String[] mKeys; - - public void setUp() throws Exception { - super.setUp(); - mMap = new HashMap(); - mKeys = new String[ITERATIONS]; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - mKeys[i] = Integer.toString(i, 16); - mMap.put(mKeys[i], i); - } - } - - public void tearDown() { - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testHashMapContainsKey() { - for (int i = ITERATIONS - 1; i >= 0; i--) { - mMap.containsKey(mKeys[i]); - } - } - - public void testHashMapIterator() { - Iterator iterator; - - iterator = mMap.entrySet().iterator(); - while (iterator.hasNext()) { - iterator.next(); - } - } - - public void testHashMapPut() { - HashMap map = new HashMap(); - String[] keys = mKeys; - for (int i = ITERATIONS - 1; i >= 0; i--) { - map.put(keys[i], i); - } - } - } - - interface IA { - void funcA0(); - void funcA1(); - void funcA2(); - void funcA3(); - } - interface IAB extends IA { - void funcAB0(); - void funcAB1(); - void funcAB2(); - void funcAB3(); - } - interface IABC extends IAB { - void funcABC0(); - void funcABC1(); - void funcABC2(); - void funcABC3(); - } - interface IB { - void funcB0(); - void funcB1(); - void funcB2(); - void funcB3(); - } - interface IC { - void funcC0(); - void funcC1(); - void funcC2(); - void funcC3(); - } - - static class Alphabet implements Cloneable, IB, IABC, IC, Runnable { - public void funcA0() { - } - public void funcA1() { - } - public void funcA2() { - } - public void funcA3() { - } - public void funcAB0() { - } - public void funcAB1() { - } - public void funcAB2() { - } - public void funcAB3() { - } - public void funcABC0() { - } - public void funcABC1() { - } - public void funcABC2() { - } - public void funcABC3() { - } - public void funcB0() { - } - public void funcB1() { - } - public void funcB2() { - } - public void funcB3() { - } - public void funcC0() { - } - public void funcC1() { - } - public void funcC2() { - } - public void funcC3() { - } - public void run() { - } - }; - - public static class InterfaceTests extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - /* call method directly */ - public void testInterfaceCalls0() { - Alphabet alpha = new Alphabet(); - - for (int i = ITERATIONS - 1; i >= 0; i--) { - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - alpha.funcABC1(); - } - } - - /* call method through interface reference */ - public void testInterfaceCalls1() { - Alphabet alpha = new Alphabet(); - IABC iabc = alpha; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - iabc.funcABC1(); - } - } - - public void testInstanceOfTrivial() { - Alphabet alpha = new Alphabet(); - IABC iabc = alpha; - boolean val; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - val = iabc instanceof Alphabet; - } - } - - public void testInstanceOfInterface() { - Alphabet alpha = new Alphabet(); - IABC iabc = alpha; - boolean val; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - val = iabc instanceof IA; - } - } - - public void testInstanceOfNot() { - Alphabet alpha = new Alphabet(); - IABC iabc = alpha; - boolean val; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - val = iabc instanceof EmptyInterface; - } - } - } - - public static class NestedLoop extends PerformanceTestBase { - private static final int ITERATIONS = 10; - private static final int LOOPS = 5; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * LOOPS); - return 0; - } - - public void testRun() { - int x = 0; - for (int a = 0; a < ITERATIONS; a++) { - for (int b = 0; b < ITERATIONS; b++) { - for (int c = 0; c < ITERATIONS; c++) { - for (int d = 0; d < ITERATIONS; d++) { - for (int e = 0; e < ITERATIONS; e++) { - x++; - } - } - } - } - } - } - } - - public static class StringConcatenationTests extends PerformanceTestBase { - private static final int ITERATIONS = 1000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testStringConcatenation1() { - StringBuffer buffer = new StringBuffer(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - buffer.append("Hello World!\n"); - } - buffer = null; - } - - public void testStringConcatenation2() { - String string = ""; - for (int i = ITERATIONS - 1; i >= 0; i--) { - string += "Hello World!\n"; - } - string = null; - } - } - - public static class StringLength extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private static final String TEST_STRING = "This is the string we use for testing..."; // 40 chars - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - String testStr = TEST_STRING; - int length; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - length = testStr.length(); - } - } - } - - public static class EmptyJniStaticMethod0 extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - int a, b, c, d, e, f; - - a = b = c = d = e = f = 0; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - } - } - } - public static class EmptyJniStaticMethod6 extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - int a, b, c, d, e, f; - - a = b = c = d = e = f = 0; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - } - } - } - public static class EmptyJniStaticMethod6L extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - String a = null; - String[] b = null; - int[][] c = null; - Object d = null; - Object[] e = null; - Object[][][][] f = null; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6L(a, b, c, d, e, f); - } - } - } - - public static class StringCrawl extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private static final String TEST_STRING = "This is the string we use for testing..."; // 40 chars - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * TEST_STRING.length()); - return 0; - } - - public void testRun() { - String testStr = TEST_STRING; - char ch; - for (int i = ITERATIONS - 1; i >= 0; i--) { - /* this is the wrong way to walk through a string */ - for (int j = 0; j < testStr.length(); j++) { - ch = testStr.charAt(j); - } - } - } - } - - public static class AddTest extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 20); - return 0; - } - - public void testRun() { - int j = 0; - for (int i = ITERATIONS - 1; i >= 0; i--) { - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - } - } - } - - public static class AddMemberVariableTest extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private int j; - - public void setUp() throws Exception { - super.setUp(); - j = 0; - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testAddMemberVariableTest() { - for (int i = ITERATIONS - 1; i >= 0; i--) { - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - j++; - } - } - - public void testAddMemberVariableInMethodTest() { - for (int i = ITERATIONS - 1; i >= 0; i--) { - add(); - add(); - add(); - add(); - add(); - add(); - add(); - add(); - add(); - add(); - } - } - - public void add() { - j++; - } - } - - private interface EmptyInterface { - public void emptyVirtual(); - - } - - private static class EmptyClass implements EmptyInterface { - public void emptyVirtual() { - } - - public static void emptyStatic() { - } - } - - public static class EmptyClassBaseTest extends PerformanceTestBase { - protected EmptyInterface mEmptyInterface; - protected EmptyClass mEmptyClass; - - public void setUp() throws Exception { - super.setUp(); - mEmptyClass = new EmptyClass(); - mEmptyInterface = mEmptyClass; - } - private static final int ITERATIONS = 10000; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testEmptyVirtualMethod() { - //EmptyClass emtpyClass = mEmptyClass; - for (int i = ITERATIONS - 1; i >= 0; i--) { - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - mEmptyClass.emptyVirtual(); - } - } - - public void testEmptyVirtualMethodTestInLocal() { - EmptyClass empty = mEmptyClass; - for (int i = ITERATIONS - 1; i >= 0; i--) { - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - empty.emptyVirtual(); - } - } - - public void testEmptyStaticMethod () { - for (int i = ITERATIONS - 1; i >= 0; i--) { - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - EmptyClass.emptyStatic(); - } - } - - public void testEmptyJniStaticMethod0() { - - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - NativeTestTarget.emptyJniStaticMethod0(); - } - } - - public void testEmptyJniStaticMethod6() { - int a, b, c, d, e, f; - - a = b = c = d = e = f = 0; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - NativeTestTarget.emptyJniStaticMethod6(a, b, c, d, e, f); - } - } - - public void testEmptyInternalStaticMethod() { - /* - * The method called is a VM-internal method with no extra - * wrapping. - */ - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - NativeTestTarget.emptyInternalStaticMethod(); - } - } - - public void testEmptyInlineStaticMethod() { - /* - * The method called is a VM-internal method that gets - * specially "inlined" in a bytecode transformation. - */ - for (int i = ITERATIONS - 1; i >= 0; i--) { - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - NativeTestTarget.emptyInlineMethod(); - } - } - - public void testEmptyInterfaceMethodTest() { - EmptyInterface emptyInterface = mEmptyInterface; - for (int i = ITERATIONS - 1; i >= 0; i--) { - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - emptyInterface.emptyVirtual(); - } - } - } - - public static class LoopTests extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - private SizeTest mSizeTest = new SizeTest(ITERATIONS); - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testForLoopTest() { - int i = 0; - for (; i < 10000; i++) { - } - } - - public void testWhileLoopTest() { - int i = 0; - - while (i < 10000) { - i++; - } - } - - public void testForLoopSizeCalledInside() { - for (int i = 0; i < mSizeTest.size(); i++) { - } - } - - public void testForLoopSizeCalledOutside() { - final int size = mSizeTest.size(); - for (int i = 0; i < size; i++) { - } - } - } - - public static class BoundsCheckTest extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - int[] data = new int[1]; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - data[0] = i; - } - } - } - - public static class ArrayListBase extends PerformanceTestBase { - public void setUp() throws Exception { - super.setUp(); - mList = new ArrayList(); - mList.add(0); - mList.add(1); - mList.add(2); - mList.add(3); - mList.add(4); - mList.add(5); - mList.add(6); - mList.add(7); - mList.add(8); - mList.add(9); - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(100); - return 0; - } - - ArrayList mList; - - public void testForArrayList() { - int i = 0; - int res = 0; - for (; i < 100; i++) { - for (int j = 0; j < mList.size(); j++) { - res += mList.get(j); - } - } - } - - public void testForLocalArrayList() { - int i = 0; - int res = 0; - for (; i < 100; i++) { - final List list = mList; - final int N = list.size(); - for (int j = 0; j < N; j++) { - res += list.get(j); - } - } - } - - public void testForEachArrayList() { - int i = 0; - int res = 0; - for (; i < 100; i++) { - for (Integer v : mList) { - res += v; - } - } - } - } - - public static class SynchronizedGetAndSetInt extends PerformanceTestBase { - private static final int ITERATIONS = 100000; - - public int mMember = 0; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testRun() { - int result = 0; - for (int i = ITERATIONS - 1; i >= 0; i--) { - synchronized (this) { - result = mMember; - mMember = i; - } - } - } - } - - public static class AtomicGetAndSetInt extends PerformanceTestBase { - private static final int ITERATIONS = 100000; - - public AtomicInteger mMember = new AtomicInteger(0); - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testRun() { - int result = 0; - for (int i = ITERATIONS - 1; i >= 0; i--) { - result = mMember.getAndSet(i); - } - } - } - - public static abstract class StringEquals extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - protected String mString1, mString2; - public void setUp() throws Exception { - super.setUp(); - } - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - String string1 = mString1; - String string2 = mString2; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - string1.equals(string2); - } - } - } - - public static class StringEquals2 extends StringEquals { - public void setUp() throws Exception { - mString1 = "01"; - mString2 = "0x"; - } - } - public static class StringEquals10 extends StringEquals { - public void setUp() throws Exception { - mString1 = "0123456789"; - mString2 = "012345678x"; - } - } - public static class StringEquals20 extends StringEquals { - public void setUp() throws Exception { - mString1 = "01234567890123456789"; - mString2 = "0123456789012345678x"; - } - } - - public static class StringEquals200 extends StringEquals { - public void setUp() throws Exception { - mString1 = "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789"; - mString2 = "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "012345678901234567890123456789012345678x"; - } - } - public static class StringEquals200U extends StringEquals { - /* make one of the strings non-word aligned (bad memcmp case) */ - public void setUp() throws Exception { - String tmpStr; - mString1 = "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789"; - tmpStr = "z0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "012345678901234567890123456789012345678x"; - mString2 = tmpStr.substring(1); - } - } - - public static abstract class StringCompareTo extends PerformanceTestBase { - private static final int ITERATIONS = 10000; - - protected String mString1, mString2; - - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS * 10); - return 0; - } - - public void testRun() { - String string1 = mString1; - String string2 = mString2; - - for (int i = ITERATIONS - 1; i >= 0; i--) { - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - string1.compareTo(string2); - } - } - } - public static class StringCompareTo10 extends StringCompareTo { - public void setUp() throws Exception { - mString1 = "0123456789"; - mString2 = "012345678x"; - } - } - public static class StringCompareTo200 extends StringCompareTo { - public void setUp() throws Exception { - mString1 = "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789"; - mString2 = "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "0123456789012345678901234567890123456789" - + "012345678901234567890123456789012345678x"; - } - } -} - diff --git a/tests/CoreTests/android/core/TreeMapPerformanceTest.java b/tests/CoreTests/android/core/TreeMapPerformanceTest.java deleted file mode 100644 index 3a210f4..0000000 --- a/tests/CoreTests/android/core/TreeMapPerformanceTest.java +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.Collection; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -/** - * Implements basic performance test functionality for java.util.TreeMap - */ - -public class TreeMapPerformanceTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public static TreeMap sMap; - public static String[] sKeys; - - @Override - @SuppressWarnings("unchecked") - protected void setUp() throws Exception { - super.setUp(); - sMap = new TreeMap(); - sKeys = new String[ITERATIONS]; - for (int i = ITERATIONS - 1; i >= 0; i--) { - sKeys[i] = Integer.toString(i, 16); - sMap.put(sKeys[i], i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - @SuppressWarnings("unchecked") - public void testTreeMapPut() { - TreeMap map = new TreeMap(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - map.put(i, i); - } - } - - public void testTreeMapGet() { - int value; - TreeMap map = sMap; - String[] keys = sKeys; - for (int i = ITERATIONS - 1; i >= 0; i--) { - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - value = map.get(keys[i]); - } - } - - public void testTreeMapFirstKey() { - String key; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - key = map.firstKey(); - } - } - - public void testTreeMapKeySet() { - Set keyset; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - keyset = map.keySet(); - } - } - - public void testTreeMapEntrySet() { - Set keyset; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - keyset = map.entrySet(); - } - } - - public void testTreeMapValues() { - Collection collection; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - collection = map.values(); - } - } - - public void testTreeMapSize() { - int len; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - len = map.size(); - } - } - - public void testTreeMapContainsKey() { - boolean flag; - String key = sKeys[525]; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - flag = map.containsKey(key); - } - } - - public void testTreeMapContainsValue() { - boolean flag; - TreeMap map = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - flag = map.containsValue(i); - } - } - - public void testTreeMapHeadMap() { - SortedMap map; - String str = sKeys[100]; - TreeMap tMap = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - map = tMap.headMap(str); - } - } - - public void testTreeMapSubMap() { - String str1 = sKeys[400]; - String str2 = sKeys[500]; - SortedMap map; - TreeMap tMap = sMap; - for (int i = ITERATIONS - 1; i >= 0; i--) { - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - map = tMap.subMap(str1, str2); - } - } - - public void testTreeMapTailMap() { - String str = sKeys[900]; - TreeMap tMap = sMap; - SortedMap map; - for (int i = ITERATIONS - 1; i >= 0; i--) { - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - map = tMap.tailMap(str); - } - } - - @SuppressWarnings("unchecked") - public void testTreeMapRemove() { - TreeMap tMap = new TreeMap(sMap); - String[] keys = sKeys; - for (int i = ITERATIONS - 1; i >= 0; i--) { - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - tMap.remove(keys[i]); - } - } -} diff --git a/tests/CoreTests/android/core/TreeSetTest.java b/tests/CoreTests/android/core/TreeSetTest.java deleted file mode 100644 index a6a3309..0000000 --- a/tests/CoreTests/android/core/TreeSetTest.java +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.TreeSet; -import java.util.SortedSet; -import java.util.Iterator; -import java.util.Comparator; - -/** - * Implements basic performance test functionality for java.util.TreeSet - */ - -public class TreeSetTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - public static TreeSet sSet; - - @Override - protected void setUp() throws Exception { - super.setUp(); - sSet = new TreeSet(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - sSet.add(i); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - /** - * - * Tests performance for the java.util.TreeSet method Add(Object arg 0) - * - */ - - @SuppressWarnings("unchecked") - public void testTreeSetAdd() { - TreeSet set = new TreeSet(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - set.add(i); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - first() - * - */ - - public void testTreeSetFirst() { - int value; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - value = set.first(); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - last() - * - */ - - public void testTreeSetLast() { - int value; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - value = set.last(); - } - } - - /** - * - * Tests performance of the java.util.TreeSet method- contains(Object arg0) - * - */ - - public void testTreeSetContains() { - Integer index = new Integer(500); - boolean flag; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - flag = set.contains(index); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - size() - * - */ - - public void testTreeSetSize() { - int value; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - value = set.size(); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - iterator() - * - */ - - public void testTreeSetIterator() { - Iterator iterator; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - iterator = set.iterator(); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - comparator() - * - */ - - public void testTreeSetComparator() { - Comparator comparator; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - comparator = set.comparator(); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - clone() - * - */ - - public void testTreeSetClone() { - Object obj; - TreeSet set = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - obj = set.clone(); - } - } - - /** - * - * Tests performance of the java.util.TreeSet method - remove(Object arg0) - * - */ - - @SuppressWarnings("unchecked") - public void testTreeSetRemove() { - TreeSet set = new TreeSet(sSet); - for (int i = ITERATIONS - 1; i >= 0; i--) { - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - set.remove(i); - } - } - - /** - * - * Tests performance of the java.util.TreeSet method- headSet(Integer arg0) - * - */ - - public void testTreeSetHeadSet() { - Integer value = new Integer(100); - SortedSet set; - TreeSet tSet = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - set = tSet.headSet(value); - } - } - - /** - * - * Tests performance of subSet(Integer arg0, Integer arg1) - TreeSet - * - */ - - public void testTreeSetSubSet() { - Integer value = new Integer(400); - Integer nInt = new Integer(500); - SortedSet set; - TreeSet tSet = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - set = tSet.subSet(value, nInt); - - } - - } - - /** - * - * Tests performance of tailSet(Integer arg0) - TreeSet - * - */ - - public void testTreeSetTailSet() { - Integer value = new Integer(900); - SortedSet set; - TreeSet tSet = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - set = tSet.tailSet(value); - } - } - - /** - * - * Tests performance for the java.util.TreeSet method - isEmpty() - * - */ - - public void testTreeSetIsEmpty() { - boolean flag; - TreeSet tSet = sSet; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - flag = tSet.isEmpty(); - } - } -} diff --git a/tests/CoreTests/android/core/VectorTest.java b/tests/CoreTests/android/core/VectorTest.java deleted file mode 100644 index b4c84fd..0000000 --- a/tests/CoreTests/android/core/VectorTest.java +++ /dev/null @@ -1,555 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.core; - -import android.test.PerformanceTestBase; -import android.test.PerformanceTestCase; - -import java.util.Vector; -import java.util.Enumeration; - -/** - * Basic Performance Tests for java.util.Vector - */ - -@SuppressWarnings("unchecked") -public class VectorTest extends PerformanceTestBase { - public static final int ITERATIONS = 1000; - private Vector mVector; - private Vector mStrVector; - private String mTestString = "Hello Android"; - - @Override - protected void setUp() throws Exception { - super.setUp(); - mVector = new Vector(); - mStrVector = new Vector(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - assertTrue(mVector.add(i)); - assertTrue(mStrVector.add(Integer.toString(i))); - } - } - - @Override - public int startPerformance(PerformanceTestCase.Intermediates intermediates) { - intermediates.setInternalIterations(ITERATIONS); - return 0; - } - - public void testVectorAdd() { - Vector vector = new Vector(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - vector.add(i); - } - } - - public void testVectorAdd1() { - Vector vector = new Vector(); - for (int i = ITERATIONS - 1; i >= 0; i--) { - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - vector.add(0, i); - } - } - - public void testVectorToArray() { - Object array; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - array = vector.toArray(); - } - } - - /** - * - */ - public void testVectorSize() { - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - int mLen; - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - mLen = vector.size(); - } - } - - public void testVectorGet() { - int element; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - element = vector.get(i); - } - - } - - public void testVectorContains() { - boolean flag; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - flag = vector.contains(i); - } - } - - public void testVectorToArray1() { - Integer[] rArray = new Integer[100]; - Integer[] array; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - array = vector.toArray(rArray); - } - } - - public void testVectorSet() { - Vector vector = mVector; - int pos = 5, value = 0; - for (int i = ITERATIONS - 1; i >= 0; i--) { - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - vector.set(pos, value); - } - } - - public void testVectorIndexOf() { - int index, value = 0; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - index = vector.indexOf(value); - } - } - - public void testVectorLastIndexOf() { - int index, value = 0; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i >= 0; i--) { - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - index = vector.lastIndexOf(value); - } - } - - public void testVectorRemove() { - int index, value = 0; - Vector vector = new Vector(mVector); - for (int i = 10; i > 0; i--) { - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - index = vector.remove(value); - } - } - - public void testVectorRemoveElement() { - Vector vector = new Vector(mVector); - for (int i = 10; i > 0; i--) { - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - vector.removeElement(i); - } - } - - public void VectorRemoveElementAt() { - Vector vector = new Vector(mVector); - for (int i = 10; i > 0; i--) { - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - vector.removeElementAt(i); - } - } - - public void VectorAddAll() { - Vector vector = new Vector(), vector1 = mVector; - - boolean flag; - for (int i = 10; i > 0; i--) { - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - flag = vector.addAll(vector1); - } - } - - public void VectorRemove1() { - Vector vector = mStrVector; - for (int j = 1000; j > 0; j--) { - vector.add("a"); - vector.add("b"); - } - String s = new String("a"); - boolean flag; - for (int i = 10; i > 0; i--) { - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - flag = vector.remove(s); - } - } - - public void testVectorAddAll1() { - Vector mEmptyVector = new Vector(); - boolean flag; - int pos = 0; - Vector vector1 = mVector; - Vector vector = mEmptyVector; - for (int i = 10; i > 0; i--) { - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - flag = vector.addAll(pos, vector1); - } - } - - public void testVectorClone() { - Object obj; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - obj = vector.clone(); - } - } - - public void testVectorCapacity() { - int capacity; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - capacity = vector.capacity(); - } - } - - public void testVectorHashcode() { - int element; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - element = vector.hashCode(); - } - } - - public void testVectorElements() { - Enumeration elements; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - elements = vector.elements(); - } - } - - public void testVectorToString() { - String str; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - str = vector.toString(); - } - } - - public void testVectorElementAt() { - int element; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - element = vector.elementAt(50); - } - } - - public void testVectorAddElement() { - int element; - Vector vector = mStrVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - vector.addElement(mTestString); - } - } - - public void testVectorFirstElement() { - int element; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - element = vector.firstElement(); - } - } - - public void testVectorLastElement() { - int element; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - element = vector.lastElement(); - } - } - - public void testVectorSetElementAt() { - Vector vector = mVector; - int value1 = 500, value2 = 50; - for (int i = ITERATIONS - 1; i > 0; i--) { - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - vector.setElementAt(value1, value2); - } - } - - public void testVectorIsEmpty() { - boolean flag; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - flag = vector.isEmpty(); - } - } - - public void testVectorCopyInto() { - Integer[] rArray = new Integer[ITERATIONS]; - Vector vector = mVector; - for (int i = ITERATIONS - 1; i > 0; i--) { - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - vector.copyInto(rArray); - } - } - - public void testVectorInsertElementAt() { - Vector vector = mStrVector; - String string = mTestString; - for (int i = ITERATIONS - 1; i > 0; i--) { - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - vector.insertElementAt(string, i); - } - } -} -- cgit v1.1