diff options
5 files changed, 178 insertions, 2 deletions
diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java index 73f36a2647..56ce8058e8 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/common/fixture/app/MultiModuleTestProject.java @@ -16,7 +16,7 @@ import java.util.Map; */ public class MultiModuleTestProject implements TestProject { - private Map<String, ? extends TestProject> subprojects; + private Map<String, TestProject> subprojects; /** * Creates a MultiModuleTestProject. @@ -24,11 +24,25 @@ public class MultiModuleTestProject implements TestProject { * @param subprojects a map with gradle project path as key and the corresponding TestProject as * value. */ - public MultiModuleTestProject(Map<String, ? extends TestProject> subprojects) { + public MultiModuleTestProject(Map<String, TestProject> subprojects) { this.subprojects = Maps.newHashMap(subprojects); } /** + * Creates a MultiModuleTestProject with multiple subproject of the same TestProject. + * + * @param baseName Base name of the subproject. Actual project name will be baseName + index. + * @param subproject A TestProject. + * @param count Number of subprojects to create. + */ + public MultiModuleTestProject(String baseName, TestProject subproject, int count) { + subprojects = Maps.newHashMapWithExpectedSize(count); + for (int i = 0; i < count; i++) { + subprojects.put(baseName + i, subproject); + } + } + + /** * Return the test project with the given project path. */ public TestProject getSubproject(String subprojectPath) { diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy index 6ea0d645c2..91b57b9122 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidComponentTest.groovy @@ -57,6 +57,8 @@ class LargeVariantAndroidComponentTest { } } """.stripIndent()).createBuildScript() + + // Execute before performance test to warm up the cache. project.execute("help"); } diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy index 40a1a4c39f..b617d14a14 100644 --- a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/LargeVariantAndroidTest.groovy @@ -54,6 +54,8 @@ class LargeVariantAndroidTest { } } """.stripIndent()).createBuildScript() + + // Execute before performance test to warm up the cache. project.execute("help"); } diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy new file mode 100644 index 0000000000..2698c8f0b4 --- /dev/null +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidComponentTest.groovy @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2015 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 com.android.build.gradle.integration.performance + +import com.android.build.gradle.integration.common.fixture.GradleTestProject +import com.android.build.gradle.integration.common.fixture.TestProject +import com.android.build.gradle.integration.common.fixture.app.AndroidTestApp +import com.android.build.gradle.integration.common.fixture.app.HelloWorldApp +import com.android.build.gradle.integration.common.fixture.app.MultiModuleTestProject +import com.android.build.gradle.integration.common.fixture.app.TestSourceFile +import com.android.build.gradle.integration.common.fixture.app.VariantBuildScriptGenerator +import org.junit.AfterClass +import org.junit.ClassRule +import org.junit.Test + +/** + * Performance test on gradle experimantal plugin with multiple subprojects and multiple variants. + */ +class MultiProjectsAndroidComponentTest { + public static AndroidTestApp app = new HelloWorldApp() + static { + app.addFile(new TestSourceFile("", "build.gradle", + new VariantBuildScriptGenerator( + buildTypes: VariantBuildScriptGenerator.MEDIUM_NUMBER, + productFlavors: VariantBuildScriptGenerator.MEDIUM_NUMBER, + """ + apply plugin: "com.android.model.application" + + model { + android.config { + compileSdkVersion $GradleTestProject.DEFAULT_COMPILE_SDK_VERSION + buildToolsVersion "$GradleTestProject.DEFAULT_BUILD_TOOL_VERSION" + } + + android.buildTypes { + \${buildTypes} + } + + android.productFlavors { + \${productFlavors} + } + } + """.stripIndent()).createBuildScript()) + ) + } + + public static TestProject baseProject = new MultiModuleTestProject("app", app, 10) + + @ClassRule + public static GradleTestProject project = GradleTestProject.builder() + .fromTestApp(baseProject) + .forExpermimentalPlugin(true) + .create() + + @AfterClass + static void cleanUp() { + app = null; + baseProject = null; + project = null; + } + + @Test + void performanceTest() { + project.execute("help") + } +} diff --git a/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy new file mode 100644 index 0000000000..3fabb6939d --- /dev/null +++ b/build-system/integration-test/src/test/groovy/com/android/build/gradle/integration/performance/MultiProjectsAndroidTest.groovy @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2015 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 com.android.build.gradle.integration.performance + +import com.android.build.gradle.integration.common.fixture.GradleTestProject +import com.android.build.gradle.integration.common.fixture.TestProject +import com.android.build.gradle.integration.common.fixture.app.AndroidTestApp +import com.android.build.gradle.integration.common.fixture.app.HelloWorldApp +import com.android.build.gradle.integration.common.fixture.app.MultiModuleTestProject +import com.android.build.gradle.integration.common.fixture.app.TestSourceFile +import com.android.build.gradle.integration.common.fixture.app.VariantBuildScriptGenerator +import org.junit.AfterClass +import org.junit.BeforeClass +import org.junit.ClassRule +import org.junit.Test + +/** + * Performance test on gradle plugin with multiple subprojects and multiple variants. + */ +class MultiProjectsAndroidTest { + public static AndroidTestApp app = new HelloWorldApp() + static { + app.addFile(new TestSourceFile("", "build.gradle", + new VariantBuildScriptGenerator( + buildTypes: VariantBuildScriptGenerator.MEDIUM_NUMBER, + productFlavors: VariantBuildScriptGenerator.MEDIUM_NUMBER, + """ + apply plugin: "com.android.application" + + android { + compileSdkVersion $GradleTestProject.DEFAULT_COMPILE_SDK_VERSION + buildToolsVersion "$GradleTestProject.DEFAULT_BUILD_TOOL_VERSION" + + buildTypes { + \${buildTypes} + } + + productFlavors { + \${productFlavors} + } + } + """.stripIndent()).createBuildScript()) + ) + } + + public static TestProject baseProject = new MultiModuleTestProject("app", app, 10) + + @ClassRule + public static GradleTestProject project = GradleTestProject.builder() + .fromTestApp(baseProject) + .create() + + @AfterClass + static void cleanUp() { + app = null; + baseProject = null; + project = null; + } + + @Test + void performanceTest() { + project.execute("help") + } +} |