jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1722346 - in /jmeter/trunk: src/core/org/apache/jmeter/gui/MainFrame.java src/core/org/apache/jmeter/reporters/Summariser.java src/jorphan/org/apache/jorphan/util/JOrphanUtils.java xdocs/changes.xml
Date Wed, 30 Dec 2015 14:59:05 GMT
Author: pmouawad
Date: Wed Dec 30 14:59:04 2015
New Revision: 1722346

URL: http://svn.apache.org/viewvc?rev=1722346&view=rev
Log:
Bug 58165 - Show the time elapsed since the start of the load test in GUI mode 
Bugzilla Id: 58165

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
    jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
    jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java?rev=1722346&r1=1722345&r2=1722346&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/MainFrame.java Wed Dec 30 14:59:04 2015
@@ -96,6 +96,7 @@ import org.apache.jmeter.threads.JMeterC
 import org.apache.jmeter.util.JMeterUtils;
 import org.apache.jorphan.gui.ComponentUtil;
 import org.apache.jorphan.logging.LoggingManager;
+import org.apache.jorphan.util.JOrphanUtils;
 import org.apache.log.LogEvent;
 import org.apache.log.LogTarget;
 import org.apache.log.Logger;
@@ -174,6 +175,11 @@ public class MainFrame extends JFrame im
     private JMeterToolBar toolbar;
 
     /**
+     * Label at top right showing test duration
+     */
+    private JLabel testTimeDuration;
+
+    /**
      * Indicator for Log errors and Fatals
      */
     private JButton warnIndicator;
@@ -185,6 +191,14 @@ public class MainFrame extends JFrame im
      * LogTarget that receives ERROR or FATAL
      */
     private transient ErrorsAndFatalsCounterLogTarget errorsAndFatalsCounterLogTarget;
+    
+    private javax.swing.Timer computeTestDurationTimer = new javax.swing.Timer(1000, new
java.awt.event.ActionListener() {
+        
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            computeTestDuration();
+        }
+    });
 
     /**
      * Create a new JMeter frame.
@@ -201,6 +215,8 @@ public class MainFrame extends JFrame im
         runningIndicator.setMargin(new Insets(0, 0, 0, 0));
         runningIndicator.setBorder(BorderFactory.createEmptyBorder());
 
+        testTimeDuration = new JLabel("00:00:00"); //$NON-NLS-1$
+
         totalThreads = new JLabel("0"); // $NON-NLS-1$
         totalThreads.setToolTipText(JMeterUtils.getResString("total_threads_tooltip")); //
$NON-NLS-1$
 
@@ -228,6 +244,14 @@ public class MainFrame extends JFrame im
         setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
     }
 
+    protected void computeTestDuration() {
+        long startTime = JMeterContextService.getTestStartTime();
+        if (startTime > 0) {
+            long elapsedSec = (System.currentTimeMillis()-startTime + 500) / 1000; // rounded
seconds
+            testTimeDuration.setText(JOrphanUtils.formatDuration(elapsedSec));
+        }
+    }
+
     /**
      * Default constructor for the JMeter frame. This constructor will not
      * properly initialize the tree, so don't use it.
@@ -413,6 +437,7 @@ public class MainFrame extends JFrame im
     @Override
     public void testStarted(String host) {
         hosts.add(host);
+        computeTestDurationTimer.start();
         runningIndicator.setIcon(runningIcon);
         activeThreads.setText("0"); // $NON-NLS-1$
         totalThreads.setText("0"); // $NON-NLS-1$
@@ -448,6 +473,7 @@ public class MainFrame extends JFrame im
         if (hosts.size() == 0) {
             runningIndicator.setIcon(stoppedIcon);
             JMeterContextService.endTest();
+            computeTestDurationTimer.stop();
         }
         menuBar.setRunning(false, host);
         if (LOCAL.equals(host)) {
@@ -558,6 +584,9 @@ public class MainFrame extends JFrame im
         toolPanel.add(Box.createRigidArea(new Dimension(10, 15)));
         toolPanel.add(Box.createGlue());
 
+        toolPanel.add(testTimeDuration);
+        toolPanel.add(Box.createRigidArea(new Dimension(20, 15)));
+
         if (DISPLAY_ERROR_FATAL_COUNTER) {
             toolPanel.add(errorsOrFatalsLabel);
             toolPanel.add(warnIndicator);

Modified: jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java?rev=1722346&r1=1722345&r2=1722346&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/reporters/Summariser.java Wed Dec 30 14:59:04
2015
@@ -252,7 +252,7 @@ public class Summariser extends Abstract
         sb.append(" in ");
         long elapsed = summariserRunningSample.getElapsed();
         long elapsedSec = (elapsed + 500) / 1000; // rounded seconds
-        sb.append(String.format("%d:%02d:%02d", elapsedSec / 3600, (elapsedSec % 3600) /
60, (elapsedSec % 60)));
+        sb.append(JOrphanUtils.formatDuration(elapsedSec));
         sb.append(" = ");
         if (elapsed > 0) {
             sb.append(doubleToSb(dfDouble, tmp, summariserRunningSample.getRate(), 6, 1));

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java?rev=1722346&r1=1722345&r2=1722346&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java Wed Dec 30 14:59:04
2015
@@ -567,4 +567,12 @@ public final class JOrphanUtils {
             offset += chunk;
         }
     }
+
+    /**
+     * @param elapsedSec long elapsed time in seconds
+     * @return String formated with format HH:mm:ss
+     */
+    public static String formatDuration(long elapsedSec) {
+        return String.format("%02d:%02d:%02d", elapsedSec / 3600, (elapsedSec % 3600) / 60,
(elapsedSec % 60));
+    }
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1722346&r1=1722345&r2=1722346&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Dec 30 14:59:04 2015
@@ -160,6 +160,7 @@ Summary
 <li><bug>57319</bug>Upgrade to HttpClient 4.5.X. With the big help from
Oleg Kalnichevski.</li>
 <li><bug>58772</bug>Deprecate MongoDB related elements</li>
 <li><bug>58782</bug>ThreadGroup : Improve ergonomy</li>
+<li><bug>58165</bug>Show the time elapsed since the start of the load test
in GUI mode. Partly based on a contribution from Maxime Chassagneux (maxime.chassagneux at
gmail.com)</li>
 </ul>
 <ch_section>Non-functional changes</ch_section>
 <ul>



Mime
View raw message