jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject [jmeter] 01/02: JMeterThread: Factor our common code related to thread details
Date Sat, 15 Feb 2020 10:13:20 GMT
This is an automated email from the ASF dual-hosted git repository.

pmouawad pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jmeter.git

commit 6ce7fd700b64ef24c54f0f9f87c58324699fad9c
Author: pmouawad <p.mouawad@ubik-ingenierie.com>
AuthorDate: Sat Feb 15 11:12:11 2020 +0100

    JMeterThread: Factor our common code related to thread details
---
 .../org/apache/jmeter/threads/JMeterThread.java     | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
index 0913268..1f3940e 100644
--- a/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
+++ b/src/core/src/main/java/org/apache/jmeter/threads/JMeterThread.java
@@ -526,6 +526,14 @@ public class JMeterThread implements Runnable, Interruptible {
         return transactionResult;
     }
 
+    private void fillThreadInformation(SampleResult result, 
+            int nbActiveThreadsInThreadGroup, 
+            int nbTotalActiveThreads) {
+        result.setGroupThreads(nbActiveThreadsInThreadGroup);
+        result.setAllThreads(nbTotalActiveThreads);
+        result.setThreadName(threadName);
+    }
+
     /**
      * Execute the sampler with its pre/post processors, timers, assertions
      * Broadcast the result to the sample listeners
@@ -545,6 +553,7 @@ public class JMeterThread implements Runnable, Interruptible {
 
         delay(pack.getTimers());
         SampleResult result = null;
+
         if (running) {
             Sampler sampler = pack.getSampler();
             result = doSampling(threadContext, sampler);
@@ -553,15 +562,11 @@ public class JMeterThread implements Runnable, Interruptible {
         if (result != null && !result.isIgnore()) {
             int nbActiveThreadsInThreadGroup = threadGroup.getNumberOfThreads();
             int nbTotalActiveThreads = JMeterContextService.getNumberOfThreads();
-            result.setGroupThreads(nbActiveThreadsInThreadGroup);
-            result.setAllThreads(nbTotalActiveThreads);
-            result.setThreadName(threadName);
+            fillThreadInformation(result, nbActiveThreadsInThreadGroup, nbTotalActiveThreads);
             SampleResult[] subResults = result.getSubResults();
             if (subResults != null) {
                 for (SampleResult subResult : subResults) {
-                    subResult.setGroupThreads(nbActiveThreadsInThreadGroup);
-                    subResult.setAllThreads(nbTotalActiveThreads);
-                    subResult.setThreadName(threadName);
+                    fillThreadInformation(subResult, nbActiveThreadsInThreadGroup, nbTotalActiveThreads);
                 }
             }
             threadContext.setPreviousResult(result);
@@ -639,9 +644,7 @@ public class JMeterThread implements Runnable, Interruptible {
             SamplePackage transactionPack, JMeterContext threadContext) {
         // Get the transaction sample result
         SampleResult transactionResult = transactionSampler.getTransactionResult();
-        transactionResult.setThreadName(threadName);
-        transactionResult.setGroupThreads(threadGroup.getNumberOfThreads());
-        transactionResult.setAllThreads(JMeterContextService.getNumberOfThreads());
+        fillThreadInformation(transactionResult, threadGroup.getNumberOfThreads(), JMeterContextService.getNumberOfThreads());
 
         // Check assertions for the transaction sample
         checkAssertions(transactionPack.getAssertions(), transactionResult, threadContext);


Mime
View raw message