Skip to content

Commit

Permalink
Merge pull request #528 from joshfriend/jfriend/faster-probe
Browse files Browse the repository at this point in the history
Run help on root project to speed up project probe
  • Loading branch information
asodja authored Jan 10, 2024
2 parents 24731f1 + 27af2ac commit 49747cb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private GradleBuildConfiguration probe(GradleConnector connector) {
GradleBuildConfiguration version;
try (ProjectConnection connection = connector.forProjectDirectory(projectDir).connect()) {
BuildEnvironment buildEnvironment = connection.getModel(BuildEnvironment.class);
new ToolingApiGradleClient(connection).runTasks(ImmutableList.of("help"), ImmutableList.of("-I", initScript.getAbsolutePath()), ImmutableList.of());
new ToolingApiGradleClient(connection).runTasks(ImmutableList.of(":help"), ImmutableList.of("-I", initScript.getAbsolutePath()), ImmutableList.of());
BuildDetails buildDetails = readBuildDetails();
JavaEnvironment javaEnvironment = buildEnvironment.getJava();
List<String> allJvmArgs = new ArrayList<>(javaEnvironment.getJvmArguments());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ genrule(
assert find("<gradle-version: $gradleVersion>").size() == 17
assert find("<daemon: true").size() == 17
assert find("<daemon: false").size() == 0
assert find("<tasks: [help]>").size() == 1
assert find("<tasks: [:help]>").size() == 1
assert find("<tasks: [${tasks.join(", ")}]>").size() == 16
assert containsOne("<invocations: 16>")
}
Expand All @@ -274,7 +274,7 @@ genrule(
assert find("<gradle-version: $gradleVersion>").size() == 12
assert find("<daemon: true").size() == 12
assert find("<daemon: false").size() == 0
assert find("<tasks: [help]>").size() == 1
assert find("<tasks: [:help]>").size() == 1
assert find("<tasks: [${tasks.join(", ")}]>").size() == 11
assert find("<invocations: 1>").size() == 12
}
Expand All @@ -290,7 +290,7 @@ genrule(
assert find("<gradle-version: $gradleVersion>").size() == 12
assert find("<daemon: true").size() == 1
assert find("<daemon: false").size() == 11
assert find("<tasks: [help]>").size() == 1
assert find("<tasks: [:help]>").size() == 1
assert find("<tasks: [${tasks.join(", ")}]>").size() == 11
assert find("<invocations: 1>").size() == 12
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest {
// Probe version, 6 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 10
logFile.find("<gradle-version: 5.0>").size() == 17
logFile.find("<tasks: [help]>").size() == 2
logFile.find("<tasks: [:help]>").size() == 2
logFile.find("<tasks: [assemble]>").size() == 9 + 16

def lines = resultFile.lines
Expand Down Expand Up @@ -54,7 +54,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest {
// Probe version, 6 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 5
logFile.find("<gradle-version: 5.0>").size() == 17
logFile.find("<tasks: [help]>").size() == 2
logFile.find("<tasks: [:help]>").size() == 2
logFile.find("<tasks: [assemble]>").size() == 4 + 16

def lines = resultFile.lines
Expand Down Expand Up @@ -91,7 +91,7 @@ class BenchmarkIntegrationTest extends AbstractProfilerIntegrationTest {
// Probe version, 6 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 2
logFile.find("<gradle-version: 5.0>").size() == 17
logFile.find("<tasks: [help]>").size() == 2
logFile.find("<tasks: [:help]>").size() == 2
logFile.find("<tasks: [assemble]>").size() == 1 + 16

def lines = resultFile.lines
Expand Down
21 changes: 13 additions & 8 deletions src/test/groovy/org/gradle/profiler/ProfilerIntegrationTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
}
help {
versions = "$minimalSupportedGradleVersion"
tasks = [help]
tasks = ["help"]
daemon = none
}
"""
Expand All @@ -416,9 +416,10 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
// Probe version, 2 scenarios have 6 warm up, 10 builds, 1 scenario has 1 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 1 + 16 + 11
logFile.find("<gradle-version: $latestSupportedGradleVersion").size() == 17
logFile.find("<tasks: [:help]>").size() == 2 // Probe version
logFile.find("<daemon: true").size() == 2 + 16 * 2
logFile.find("<daemon: false").size() == 11
logFile.find("<tasks: [help]>").size() == 2 + 11
logFile.find("<tasks: [help]>").size() == 11
logFile.find("<tasks: [assemble]>").size() == 16 * 2

logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 1/3)")
Expand Down Expand Up @@ -460,8 +461,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
then:
// Probe version, 6 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 17
logFile.find("<tasks: [:help]>").size() == 1 // Probe version
logFile.find("<daemon: true").size() == 17
logFile.find("<tasks: [help]>").size() == 1
logFile.find("<tasks: []>").size() == 16

logFile.containsOne("* Running scenario xyz using Gradle $minimalSupportedGradleVersion (scenario 1/1)")
Expand Down Expand Up @@ -498,7 +499,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {

then:
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 7
logFile.find("<tasks: [help]>").size() == 4
logFile.find("<tasks: [:help]>").size() == 1 // Probe version
logFile.find("<tasks: [help]>").size() == 3
logFile.find("<tasks: [assemble]>").size() == 3

logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/2)")
Expand Down Expand Up @@ -533,7 +535,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
then:
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 7
logFile.find("<gradle-version: $latestSupportedGradleVersion>").size() == 7
logFile.find("<tasks: [help]>").size() == 8
logFile.find("<tasks: [:help]>").size() == 2 // Probe version
logFile.find("<tasks: [help]>").size() == 6
logFile.find("<tasks: [assemble]>").size() == 6

logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)")
Expand Down Expand Up @@ -581,8 +584,9 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
then:
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 7
logFile.find("<gradle-version: $latestSupportedGradleVersion>").size() == 7
logFile.find("<tasks: [:help]>").size() == 2 // Probe version
logFile.find("<tasks: [assemble]>").size() == 6
logFile.find("<tasks: [help]>").size() == 8
logFile.find("<tasks: [help]>").size() == 6

logFile.containsOne("* Running scenario assemble using Gradle $minimalSupportedGradleVersion (scenario 1/4)")
logFile.containsOne("* Running scenario assemble using Gradle $latestSupportedGradleVersion (scenario 2/4)")
Expand Down Expand Up @@ -618,7 +622,8 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
then:
// Probe version, 6 warm up, 10 builds
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 33
logFile.find("<tasks: [help]>").size() == 17
logFile.find("<tasks: [:help]>").size() == 1
logFile.find("<tasks: [help]>").size() == 16

def lines = resultFile.lines
lines.size() == totalLinesForExecutions(16)
Expand Down Expand Up @@ -691,9 +696,9 @@ class ProfilerIntegrationTest extends AbstractProfilerIntegrationTest {
// Probe version, 1 warm up, 1 build
logFile.find("<gradle-version: $minimalSupportedGradleVersion>").size() == 5
logFile.find("<gradle-version: $latestSupportedGradleVersion").size() == 3
logFile.find("<tasks: [:help]>").size() == 2
logFile.find("<dry-run: false>").size() == 2
logFile.find("<dry-run: true>").size() == 6
logFile.find("<tasks: [help]>").size() == 2
logFile.find("<tasks: [assemble]>").size() == 4
logFile.find("<tasks: [clean, assemble]>").size() == 2

Expand Down

0 comments on commit 49747cb

Please sign in to comment.