You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2012/08/19 03:02:39 UTC

svn commit: r1374690 - in /jmeter/trunk: src/core/org/apache/jmeter/threads/JMeterContextService.java xdocs/changes.xml

Author: sebb
Date: Sun Aug 19 01:02:38 2012
New Revision: 1374690

URL: http://svn.apache.org/viewvc?rev=1374690&view=rev
Log:
Keep track of number of threads started and finished
Update context service to collec the counts and return them
Bugzilla Id: 53738

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java?rev=1374690&r1=1374689&r2=1374690&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterContextService.java Sun Aug 19 01:02:38 2012
@@ -39,6 +39,12 @@ public final class JMeterContextService 
     private static int numberOfActiveThreads = 0;
 
     //@GuardedGy("this")
+    private static int numberOfThreadsStarted = 0;
+
+    //@GuardedGy("this")
+    private static int numberOfThreadsFinished = 0;
+
+    //@GuardedGy("this")
     private static int totalThreads = 0;
 
     /**
@@ -92,6 +98,7 @@ public final class JMeterContextService 
      */
     static synchronized void incrNumberOfThreads() {
         numberOfActiveThreads++;
+        numberOfThreadsStarted++;
     }
 
     /**
@@ -99,6 +106,7 @@ public final class JMeterContextService 
      */
     static synchronized void decrNumberOfThreads() {
         numberOfActiveThreads--;
+        numberOfThreadsFinished++;
     }
 
     /**
@@ -109,6 +117,11 @@ public final class JMeterContextService 
         return numberOfActiveThreads;
     }
 
+    // return all the associated counts together
+    public static synchronized ThreadCounts getThreadCounts() {
+        return new ThreadCounts(numberOfActiveThreads, numberOfThreadsStarted, numberOfThreadsFinished);
+    }
+
     /**
      * Called by MainFrame#testEnded().
      * Clears start time field.
@@ -138,9 +151,27 @@ public final class JMeterContextService 
     }
 
     /**
-     * Set total threads to zero
+     * Set total threads to zero; also clears started and finished counts
      */
     public static synchronized void clearTotalThreads() {
         totalThreads = 0;
+        numberOfThreadsStarted = 0;
+        numberOfThreadsFinished = 0;
     }
+
+    public static class ThreadCounts {
+        
+        public final int activeThreads;
+        
+        public final int startedThreads;
+        
+        public final int finishedThreads;
+        
+        ThreadCounts (int active, int started, int finished) {
+            activeThreads = active;
+            startedThreads = started;
+            finishedThreads = finished;
+        }
+    }
+
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1374690&r1=1374689&r2=1374690&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Aug 19 01:02:38 2012
@@ -135,6 +135,7 @@ JSR223 Test Elements using Script file a
 <li><bugzilla>53566</bugzilla> - Don't log partial responses to the jmeter log</li>
 <li><bugzilla>53716</bugzilla> - Small improvements in aggregate graph: legend at left or right is now on 1 column (instead of 1 large line), no border to the reference's square color, reduce width on some fields</li>
 <li><bugzilla>53718</bugzilla> - Add a new visualizer to draw a line graph showing the evolution of response time for a test</li>
+<li><bugzilla>53738</bugzilla> - Keep track of number of threads started and finished</li>
 </ul>
 
 <h3>Timers, Assertions, Config, Pre- &amp; Post-Processors</h3>