commit 4c384067b7a4ef21c1d973d344409b653b7fad2f Author: Mauro Talevi <mauro.tal...@aquilonia.org> AuthorDate: Thu, 2 Apr 2015 13:25:14 +0200 Commit: Mauro Talevi <mauro.tal...@aquilonia.org> CommitDate: Thu, 2 Apr 2015 13:25:29 +0200
JBEHAVE-1073: Added thread average story duration when running in multi-threading mode. diff --git a/examples/core/pom.xml b/examples/core/pom.xml index 342f699..73815ca 100755 --- a/examples/core/pom.xml +++ b/examples/core/pom.xml @@ -12,6 +12,7 @@ <properties> <embeddables>**/CoreStories.java</embeddables> <meta.filter></meta.filter> + <threads>2</threads> <ignore.failure.in.stories>true</ignore.failure.in.stories> <ignore.failure.in.view>true</ignore.failure.in.view> </properties> @@ -35,7 +36,7 @@ <generateViewAfterStories>true</generateViewAfterStories> <ignoreFailureInStories>${ignore.failure.in.stories}</ignoreFailureInStories> <ignoreFailureInView>${ignore.failure.in.view}</ignoreFailureInView> - <threads>2</threads> + <threads>${threads}</threads> <metaFilters> <metaFilter>${meta.filter}</metaFilter> </metaFilters> diff --git a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java index 2b0ede9..73c2f3b 100644 --- a/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java +++ b/jbehave-core/src/main/java/org/jbehave/core/embedder/StoryManager.java @@ -220,7 +220,11 @@ public class StoryManager { future.cancel(true); } } + int threads = embedderControls.threads(); + long threadAverage = total / threads; storyDurations.setProperty("total", Long.toString(total)); + storyDurations.setProperty("threads", Long.toString(threads)); + storyDurations.setProperty("threadAverage", Long.toString(threadAverage)); write(storyDurations, "storyDurations.props"); } diff --git a/jbehave-core/src/main/resources/ftl/jbehave-reports-with-totals.ftl b/jbehave-core/src/main/resources/ftl/jbehave-reports-with-totals.ftl index 52cd4ee..c24c68f 100755 --- a/jbehave-core/src/main/resources/ftl/jbehave-reports-with-totals.ftl +++ b/jbehave-core/src/main/resources/ftl/jbehave-reports-with-totals.ftl @@ -197,6 +197,20 @@ Totals </td> </tr> + +<#assign threads = storyDurations.get('threads')!1> +<#if (threads != 1) > +<tr class="totals"> +<td colspan="18"/> +<td> +<@renderTime storyDurations.get('threadAverage')!0/> +</td> +<td> +${threads}-Thread Average +</td> +</tr> +</#if> + </table> <br /> </div>