commit 8ea8f9e58e7cb879c23bb4f4fff00d15592c3600
Author: Mauro Talevi <[email protected]>
AuthorDate: Thu, 2 Apr 2015 13:25:14 +0200
Commit: Mauro Talevi <[email protected]>
CommitDate: Thu, 2 Apr 2015 13:25:14 +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 0e0f7eb..686c73d 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 123084a..dec454b 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
@@ -200,7 +200,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>