From b40da93cda1de86569523f3ac2edc4036fe88e16 Mon Sep 17 00:00:00 2001
From: Christian Wulf <chw@informatik.uni-kiel.de>
Date: Tue, 3 Jun 2014 23:09:44 +0200
Subject: [PATCH] worked on performance bug

---
 .../teetime/framework/concurrent/WorkerThread.java  | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/teetime/framework/concurrent/WorkerThread.java b/src/main/java/teetime/framework/concurrent/WorkerThread.java
index 309265e..aebf09d 100644
--- a/src/main/java/teetime/framework/concurrent/WorkerThread.java
+++ b/src/main/java/teetime/framework/concurrent/WorkerThread.java
@@ -40,6 +40,8 @@ public class WorkerThread extends Thread {
 
 	private final StopWatch stopWatch = new StopWatch();
 	private final StopWatch iterationStopWatch = new StopWatch();
+	private final StopWatch beforeStageExecutionStopWatch = new StopWatch();
+	private final StopWatch afterStageExecutionStopWatch = new StopWatch();
 	private final StopWatch stageExecutionStopWatch = new StopWatch();
 	private final List<Long> schedulingOverheadsInNs = new LinkedList<Long>();
 	private long durationInNs;
@@ -71,18 +73,23 @@ public class WorkerThread extends Thread {
 			final IStage stage = this.stageScheduler.get();
 
 			this.startStageExecution(stage);
-//			stageExecutionStopWatch.start();	// expensive: takes 1/3 of overall time
+			stageExecutionStopWatch.start();	// expensive: takes 1/3 of overall time
 			final boolean executedSuccessfully = stage.execute();
-//			stageExecutionStopWatch.end();
+			stageExecutionStopWatch.end();
 			this.finishStageExecution(stage, executedSuccessfully);
 
+			afterStageExecutionStopWatch.start();
+
 			if (this.shouldTerminate) {
 				this.executeTerminationPolicy(stage, executedSuccessfully);
 			}
 			this.stageScheduler.determineNextStage(stage, executedSuccessfully);
 
+			afterStageExecutionStopWatch.end();
+
 			this.iterationStopWatch.end();
-			final long schedulingOverhead = this.iterationStopWatch.getDurationInNs() - stageExecutionStopWatch.getDurationInNs();
+//			final long schedulingOverhead = this.iterationStopWatch.getDurationInNs() - stageExecutionStopWatch.getDurationInNs();
+			final long schedulingOverhead = afterStageExecutionStopWatch.getDurationInNs();
 			schedulingOverheadInNs += schedulingOverhead;
 			if ((iterations % 10000) == 0) {
 				this.schedulingOverheadsInNs.add(schedulingOverheadInNs);
-- 
GitLab