You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/07/10 23:31:50 UTC
svn commit: r1359911 -
/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
Author: pmouawad
Date: Tue Jul 10 21:31:50 2012
New Revision: 1359911
URL: http://svn.apache.org/viewvc?rev=1359911&view=rev
Log:
Factor out similar code
Modified:
jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java?rev=1359911&r1=1359910&r2=1359911&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/threads/JMeterThread.java Tue Jul 10 21:31:50 2012
@@ -208,26 +208,7 @@ public class JMeterThread implements Run
*/
private void startScheduler() {
long delay = (startTime - System.currentTimeMillis());
- if (delay > 0) {
- long start = System.currentTimeMillis();
- long end = start + delay;
- long now=0;
- long pause = RAMPUP_GRANULARITY;
- while(running && (now = System.currentTimeMillis()) < end) {
- long togo = end - now;
- if (togo < pause) {
- pause = togo;
- }
- try {
- Thread.sleep(pause); // delay between checks
- } catch (InterruptedException e) {
- if (running) { // Don't bother reporting stop test interruptions
- log.warn("startScheduler delay for "+threadName+" was interrupted. Waited "+(now - start)+" milli-seconds out of "+delay);
- }
- break;
- }
- }
- }
+ delayBy(delay, "startScheduler");
}
public void setThreadName(String threadName) {
@@ -797,9 +778,18 @@ public class JMeterThread implements Run
* Initial delay if ramp-up period is active for this threadGroup.
*/
private void rampUpDelay() {
- if (initialDelay > 0) {
+ delayBy(initialDelay, "RampUp");
+ }
+
+ /**
+ * Wait for delay with RAMPUP_GRANULARITY
+ * @param delay delay in ms
+ * @param type Delay type
+ */
+ protected final void delayBy(long delay, String type) {
+ if (delay > 0) {
long start = System.currentTimeMillis();
- long end = start + initialDelay;
+ long end = start + delay;
long now=0;
long pause = RAMPUP_GRANULARITY;
while(running && (now = System.currentTimeMillis()) < end) {
@@ -811,7 +801,7 @@ public class JMeterThread implements Run
Thread.sleep(pause); // delay between checks
} catch (InterruptedException e) {
if (running) { // Don't bother reporting stop test interruptions
- log.warn("RampUp delay for "+threadName+" was interrupted. Waited "+(now - start)+" milli-seconds out of "+initialDelay);
+ log.warn(type+" delay for "+threadName+" was interrupted. Waited "+(now - start)+" milli-seconds out of "+delay);
}
break;
}