You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/01 15:02:46 UTC
[lucene-solr] branch master updated: LUCENE-9818: print slowest
suites, add an option to enable/ disable the function from options. (#2439)
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 7dc43f4 LUCENE-9818: print slowest suites, add an option to enable/ disable the function from options. (#2439)
7dc43f4 is described below
commit 7dc43f46fd85a5b47fe3ac5aa68d4d21eb4d65e5
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Mon Mar 1 16:02:18 2021 +0100
LUCENE-9818: print slowest suites, add an option to enable/ disable the function from options. (#2439)
---
gradle/testing/slowest-tests-at-end.gradle | 75 +++++++++++++++++++++++-------
1 file changed, 58 insertions(+), 17 deletions(-)
diff --git a/gradle/testing/slowest-tests-at-end.gradle b/gradle/testing/slowest-tests-at-end.gradle
index 835e639..eaf9cd1 100644
--- a/gradle/testing/slowest-tests-at-end.gradle
+++ b/gradle/testing/slowest-tests-at-end.gradle
@@ -18,31 +18,72 @@
// Add test duration summary at the end of the build.
def allTests = []
+def allSuites = []
allprojects {
- tasks.withType(Test) { task ->
- afterTest { desc, result ->
- def duration = (result.getEndTime() - result.getStartTime())
-
- allTests << [
- name : "${desc.className.replaceAll('.+\\.', "")}.${desc.name} (${project.path})",
- duration: duration
+ plugins.withType(JavaPlugin) {
+ ext {
+ testOptions += [
+ [propName: 'tests.slowestTests', value: true, description: "Print the summary of the slowest tests."],
+ [propName: 'tests.slowestSuites', value: true, description: "Print the summary of the slowest suites."]
]
}
+
+ tasks.withType(Test) { task ->
+ if (resolvedTestOption("tests.slowestTests").toBoolean()) {
+ afterTest { desc, result ->
+ def duration = (result.getEndTime() - result.getStartTime())
+
+ allTests << [
+ name : "${desc.className.replaceAll('.+\\.', "")}.${desc.name} (${project.path})",
+ duration: duration
+ ]
+ }
+ }
+
+ if (resolvedTestOption("tests.slowestSuites").toBoolean()) {
+ afterSuite { desc, result ->
+ // Gradle reports runner times as well, omit anything that isn't attached to a concrete class.
+ if (desc.className != null) {
+ def duration = (result.getEndTime() - result.getStartTime())
+
+ allSuites << [
+ name : "${desc.className.replaceAll('.+\\.', "")} (${project.path})",
+ duration: duration
+ ]
+ }
+ }
+ }
+ }
}
}
gradle.buildFinished { result ->
- if (allTests && result.getFailure() == null) {
- def slowest = allTests
- .sort { a, b -> b.duration.compareTo(a.duration) }
- .take(10)
- .findAll { e -> e.duration >= 500 }
- .collect { e -> String.format(Locale.ROOT, "%5.2fs %s", e.duration / 1000d, e.name) }
-
- if (slowest) {
- logger.lifecycle("The slowest tests (exceeding 500 ms) during this run:\n " +
- slowest.join("\n "))
+ if (result.getFailure() == null) {
+ if (allTests) {
+ def slowest = allTests
+ .sort { a, b -> b.duration.compareTo(a.duration) }
+ .take(10)
+ .findAll { e -> e.duration >= 500 }
+ .collect { e -> String.format(Locale.ROOT, "%5.2fs %s", e.duration / 1000d, e.name) }
+
+ if (slowest) {
+ logger.lifecycle("The slowest tests (exceeding 500 ms) during this run:\n " +
+ slowest.join("\n "))
+ }
+ }
+
+ if (allSuites) {
+ def slowest = allSuites
+ .sort { a, b -> b.duration.compareTo(a.duration) }
+ .take(10)
+ .findAll { e -> e.duration >= 1000 }
+ .collect { e -> String.format(Locale.ROOT, "%5.2fs %s", e.duration / 1000d, e.name) }
+
+ if (slowest) {
+ logger.lifecycle("The slowest suites (exceeding 1s) during this run:\n " +
+ slowest.join("\n "))
+ }
}
}
}