Bug 50080

Summary: Transaction controller incorrectly creates samples including timer duration
Product: JMeter - Now in Github Reporter: jens_0
Component: MainAssignee: JMeter issues mailing list <issues>
Status: RESOLVED FIXED    
Severity: normal CC: jens_0
Priority: P2    
Version: 2.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description jens_0 2010-10-12 08:18:43 UTC
When using the settings "Generate parent sample" checked and "Include timer duration in generated sample" unchecked, samples generated by the transaction controller nevertheless include the duration of timers that are existing as children.

When "Generate parent sample" is unchecked, the reported times correctly do not include the timers.

With other words: "Include timer duration in generated sample" does not have any effect if "Generate parent sample" is checked.
Comment 1 Milamber 2010-10-14 03:38:40 UTC
Excludes timer option came with the Bug 41418, but the patch 41418 don't manage Excludes timer when Generate parent is on.

(in code : Bug 41418 => TC.next2() but not TC.next1())

It's seems hard to solve.
Comment 2 jens_0 2010-10-27 10:33:14 UTC
Here's a suggestion to solve the problem.

It requires changing the visibility of SampleResult's setEndTime from protected to public.

Any concerns?

original/src/core/org/apache/jmeter/control/TransactionSampler.java Thu Jul 08 22:42:36 2010
+++ new/src/core/org/apache/jmeter/control/TransactionSampler.java Wed Oct 27 16:19:32 2010
@@ -49,0 +50,2 @@
+    private int totalTime = 0;
+   
@@ -101,0 +104 @@
+        totalTime += res.getTime();
@@ -113,0 +117,8 @@
+       
+        if (!transactionController.isIncludeTimers()) {
+         long end = SampleResult.currentTimeInMs();
+         
+         transactionSampleResult.setIdleTime(end - transactionSampleResult.getStartTime() - totalTime);
+         transactionSampleResult.setEndTime(end);
+        }
+
Comment 3 jens_0 2010-10-28 04:50:25 UTC
(In reply to comment #2)
Or without changing the visibility of setEndTime:

src/core/org/apache/jmeter/control/TransactionSampler.java
 
@@ -49,0 +50,2 @@
+    private int totalTime = 0;
+   
@@ -65 +67,2 @@
-        transactionSampleResult.sampleStart();
+        if (transactionController.isIncludeTimers())
+         transactionSampleResult.sampleStart();
@@ -101 +104,9 @@
-        transactionSampleResult.addSubResult(res);
+        if (transactionController.isIncludeTimers()) {
+         transactionSampleResult.addSubResult(res);
+        } else {
+         transactionSampleResult.setBytes(transactionSampleResult.getBytes() + res.getBytes());
+         transactionSampleResult.addRawSubResult(res);
+         
+         totalTime += res.getTime();
+        }
+       
@@ -112,0 +124,7 @@
+        }
+       
+        if (!transactionController.isIncludeTimers()) {
+         long end = SampleResult.currentTimeInMs();
+         transactionSampleResult.setStampAndTime(end - totalTime, totalTime);
+         //transactionSampleResult.setIdleTime(end - transactionSampleResult.getStartTime() - totalTime);
+         //transactionSampleResult.setEndTime(end);
Comment 4 Milamber 2010-10-28 15:14:39 UTC
Thanks for your work and patch.
The first approach seems better. The second approach comes with more changes in internal logic (addRawSubResult / setBytes vs addSubResult)
I thinks changing visibility to public for setEndTime() isn't a problem.

(next time: please used the file attachment field for your patch, Bugzilla cutting long lines)

URL: http://svn.apache.org/viewvc?rev=1028437&view=rev
Log:
Bug 50080 - Transaction controller incorrectly creates samples including timer duration

Modified:
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/control/TransactionSampler.java
    jakarta/jmeter/trunk/src/core/org/apache/jmeter/samplers/SampleResult.java
    jakarta/jmeter/trunk/xdocs/changes.xml
Comment 5 The ASF infrastructure team 2022-09-24 20:37:45 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2411