forked from gradle/gradle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spiked making performance testing outside of the gradle main project.…
… It's not really possible as I need various things: 1. good way of running gradle (tooling api is almost there) 2. good way of using previous versions of gradle So... the performance testing probably goes under the main gradle project.
- Loading branch information
1 parent
7159511
commit 6c728f2
Showing
2 changed files
with
54 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 45 additions & 3 deletions
48
performanceTest/src/test/groovy/org/gradle/peformance/PerformanceTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,56 @@ | ||
package org.gradle.peformance | ||
|
||
import spock.lang.Specification | ||
import org.gradle.tooling.GradleConnector | ||
|
||
/** | ||
* by Szczepan Faber, created at: 2/9/12 | ||
*/ | ||
class PerformanceTest extends Specification { | ||
|
||
def "foo"() { | ||
expect: | ||
1==1 | ||
def "small project"() { | ||
given: | ||
def projectDir = findProjectDir("small") | ||
|
||
when: | ||
int m6result = executionTime { | ||
def connection = GradleConnector.newConnector() | ||
.forProjectDirectory(projectDir) | ||
.searchUpwards(false) | ||
.useGradleVersion("1.0-milestone-6") | ||
.connect() | ||
|
||
connection.newBuild().forTasks('clean', 'build').run() | ||
} | ||
|
||
int m7result = executionTime { | ||
def connection = GradleConnector.newConnector() | ||
.forProjectDirectory(projectDir) | ||
.searchUpwards(false) | ||
.useGradleVersion("1.0-milestone-7") | ||
.connect() | ||
|
||
connection.newBuild().forTasks('clean', 'build').run() | ||
} | ||
|
||
then: | ||
m7result <= m6result | ||
} | ||
|
||
long executionTime(Closure operation) { | ||
long before = System.currentTimeMillis() | ||
operation() | ||
return System.currentTimeMillis() - before | ||
} | ||
|
||
File findProjectDir(String name) { | ||
def projectDir = new File("build/small").absoluteFile | ||
if (!projectDir.isDirectory()) { | ||
def message = "Looks like the sample '$name' was not generated.\n" + | ||
"I've tried to find it at: $projectDir\n" + | ||
"Please run 'gradle $name' to generate the sample." | ||
assert false: message | ||
} | ||
projectDir | ||
} | ||
} |