You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2008/07/06 23:47:15 UTC
svn commit: r674351 [5/11] - in /jakarta/jmeter/trunk/src:
components/org/apache/jmeter/config/ components/org/apache/jmeter/control/
components/org/apache/jmeter/control/gui/
components/org/apache/jmeter/extractor/
components/org/apache/jmeter/extract...
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -34,136 +34,136 @@
* This class implements a constant throughput timer. A Constant Throughtput
* Timer paces the samplers under its influence so that the total number of
* samples per unit of time approaches a given constant as much as possible.
- *
+ *
* There are two different ways of pacing the requests:
* - delay each thread according to when it last ran
- * - delay each thread according to when any thread last ran
+ * - delay each thread according to when any thread last ran
*/
public class ConstantThroughputTimer extends AbstractTestElement implements Timer, TestListener, TestBean {
- private static final long serialVersionUID = 3;
+ private static final long serialVersionUID = 3;
private static class ThroughputInfo{
final Object MUTEX = new Object();
long lastScheduledTime = 0;
}
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
- private static final double MILLISEC_PER_MIN = 60000.0;
+ private static final double MILLISEC_PER_MIN = 60000.0;
- /**
- * Target time for the start of the next request. The delay provided by the
- * timer will be calculated so that the next request happens at this time.
- */
- private long previousTime = 0;
+ /**
+ * Target time for the start of the next request. The delay provided by the
+ * timer will be calculated so that the next request happens at this time.
+ */
+ private long previousTime = 0;
- private String calcMode; // String representing the mode
- // (Locale-specific)
+ private String calcMode; // String representing the mode
+ // (Locale-specific)
- private int modeInt; // mode as an integer
+ private int modeInt; // mode as an integer
- /**
- * Desired throughput, in samples per minute.
- */
- private double throughput;
+ /**
+ * Desired throughput, in samples per minute.
+ */
+ private double throughput;
//For calculating throughput across all threads
private final static ThroughputInfo allThreadsInfo = new ThroughputInfo();
-
+
//For holding the ThrougputInfo objects for all ThreadGroups. Keyed by ThreadGroup objects
private final static Map threadGroupsInfoMap = new Hashtable();
-
- /**
- * Constructor for a non-configured ConstantThroughputTimer.
- */
- public ConstantThroughputTimer() {
- }
-
- /**
- * Sets the desired throughput.
- *
- * @param throughput
- * Desired sampling rate, in samples per minute.
- */
- public void setThroughput(double throughput) {
- this.throughput = throughput;
- }
-
- /**
- * Gets the configured desired throughput.
- *
- * @return the rate at which samples should occur, in samples per minute.
- */
- public double getThroughput() {
- return throughput;
- }
-
- public String getCalcMode() {
- return calcMode;
- }
- // Needed by test code
+ /**
+ * Constructor for a non-configured ConstantThroughputTimer.
+ */
+ public ConstantThroughputTimer() {
+ }
+
+ /**
+ * Sets the desired throughput.
+ *
+ * @param throughput
+ * Desired sampling rate, in samples per minute.
+ */
+ public void setThroughput(double throughput) {
+ this.throughput = throughput;
+ }
+
+ /**
+ * Gets the configured desired throughput.
+ *
+ * @return the rate at which samples should occur, in samples per minute.
+ */
+ public double getThroughput() {
+ return throughput;
+ }
+
+ public String getCalcMode() {
+ return calcMode;
+ }
+
+ // Needed by test code
int getCalcModeInt() {
return modeInt;
}
- public void setCalcMode(String mode) {
+ public void setCalcMode(String mode) {
this.calcMode = mode;
// TODO find better way to get modeInt
- this.modeInt = ConstantThroughputTimerBeanInfo.getCalcModeAsInt(calcMode);
- }
+ this.modeInt = ConstantThroughputTimerBeanInfo.getCalcModeAsInt(calcMode);
+ }
- /**
- * Retrieve the delay to use during test execution.
- *
- * @see org.apache.jmeter.timers.Timer#delay()
- */
- public long delay() {
- long currentTime = System.currentTimeMillis();
+ /**
+ * Retrieve the delay to use during test execution.
+ *
+ * @see org.apache.jmeter.timers.Timer#delay()
+ */
+ public long delay() {
+ long currentTime = System.currentTimeMillis();
- /*
+ /*
* If previous time is zero, then target will be in the past.
* This is what we want, so first sample is run without a delay.
*/
long currentTarget = previousTime + calculateDelay();
- if (currentTime > currentTarget) {
- // We're behind schedule -- try to catch up:
+ if (currentTime > currentTarget) {
+ // We're behind schedule -- try to catch up:
previousTime = currentTime;
- return 0;
- }
+ return 0;
+ }
previousTime = currentTarget;
- return currentTarget - currentTime;
- }
+ return currentTarget - currentTime;
+ }
- /**
- * @param currentTime
- * @return new Target time
- */
+ /**
+ * @param currentTime
+ * @return new Target time
+ */
// TODO - is this used? (apart from test code)
- protected long calculateCurrentTarget(long currentTime) {
- return currentTime + calculateDelay();
- }
-
- // Calculate the delay based on the mode
- private long calculateDelay() {
- long delay = 0;
+ protected long calculateCurrentTarget(long currentTime) {
+ return currentTime + calculateDelay();
+ }
+
+ // Calculate the delay based on the mode
+ private long calculateDelay() {
+ long delay = 0;
// N.B. we fetch the throughput each time, as it may vary during a test
- double msPerRequest = (MILLISEC_PER_MIN / getThroughput());
- switch (modeInt) {
- case 1: // Total number of threads
- delay = (long) (JMeterContextService.getNumberOfThreads() * msPerRequest);
- break;
-
- case 2: // Active threads in this group
- delay = (long) (JMeterContextService.getContext().getThreadGroup().getNumberOfThreads() * msPerRequest);
- break;
-
+ double msPerRequest = (MILLISEC_PER_MIN / getThroughput());
+ switch (modeInt) {
+ case 1: // Total number of threads
+ delay = (long) (JMeterContextService.getNumberOfThreads() * msPerRequest);
+ break;
+
+ case 2: // Active threads in this group
+ delay = (long) (JMeterContextService.getContext().getThreadGroup().getNumberOfThreads() * msPerRequest);
+ break;
+
case 3: // All threads - alternate calculation
delay = calculateSharedDelay(allThreadsInfo,(long) msPerRequest);
break;
-
+
case 4: //All threads in this group - alternate calculation
- final org.apache.jmeter.threads.ThreadGroup group =
+ final org.apache.jmeter.threads.ThreadGroup group =
JMeterContextService.getContext().getThreadGroup();
ThroughputInfo groupInfo;
synchronized (threadGroupsInfoMap) {
@@ -175,13 +175,13 @@
}
delay = calculateSharedDelay(groupInfo,(long) msPerRequest);
break;
-
- default: // e.g. 0
- delay = (long) msPerRequest; // i.e. * 1
- break;
- }
- return delay;
- }
+
+ default: // e.g. 0
+ delay = (long) msPerRequest; // i.e. * 1
+ break;
+ }
+ return delay;
+ }
private long calculateSharedDelay(ThroughputInfo info, long milliSecPerRequest) {
final long now = System.currentTimeMillis();
@@ -194,7 +194,7 @@
info.lastScheduledTime = Math.max(now, nextRequstTime);
calculatedDelay = info.lastScheduledTime - now;
}
-
+
return Math.max(calculatedDelay, 0);
}
@@ -202,61 +202,61 @@
allThreadsInfo.lastScheduledTime = 0;
threadGroupsInfoMap.clear();
previousTime = 0;
- }
+ }
+
+ /**
+ * Provide a description of this timer class.
+ *
+ * TODO: Is this ever used? I can't remember where. Remove if it isn't --
+ * TODO: or obtain text from bean's displayName or shortDescription.
+ *
+ * @return the description of this timer class.
+ */
+ public String toString() {
+ return JMeterUtils.getResString("constant_throughput_timer_memo"); //$NON-NLS-1$
+ }
- /**
- * Provide a description of this timer class.
- *
- * TODO: Is this ever used? I can't remember where. Remove if it isn't --
- * TODO: or obtain text from bean's displayName or shortDescription.
- *
- * @return the description of this timer class.
- */
- public String toString() {
- return JMeterUtils.getResString("constant_throughput_timer_memo"); //$NON-NLS-1$
- }
-
- /**
- * Get the timer ready to compute delays for a new test.
- *
- * @see org.apache.jmeter.testelement.TestListener#testStarted()
- */
- public void testStarted()
- {
- log.debug("Test started - reset throughput calculation.");
+ /**
+ * Get the timer ready to compute delays for a new test.
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testStarted()
+ */
+ public void testStarted()
+ {
+ log.debug("Test started - reset throughput calculation.");
reset();
- }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testEnded()
+ */
+ public void testEnded() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testStarted(java.lang.String)
+ */
+ public void testStarted(String host) {
+ testStarted();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testEnded(java.lang.String)
+ */
+ public void testEnded(String host) {
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.testelement.TestListener#testEnded()
- */
- public void testEnded() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.testelement.TestListener#testStarted(java.lang.String)
- */
- public void testStarted(String host) {
- testStarted();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.testelement.TestListener#testEnded(java.lang.String)
- */
- public void testEnded(String host) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.LoopIterationEvent)
- */
- public void testIterationStart(LoopIterationEvent event) {
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.testelement.TestListener#testIterationStart(org.apache.jmeter.engine.event.LoopIterationEvent)
+ */
+ public void testIterationStart(LoopIterationEvent event) {
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantThroughputTimerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -25,44 +25,44 @@
/**
* BeanInfo for the ConstantThroughputTimer.
- *
+ *
*/
public class ConstantThroughputTimerBeanInfo extends BeanInfoSupport {
- private static final String[] tags = new String[5];
+ private static final String[] tags = new String[5];
- public ConstantThroughputTimerBeanInfo() {
- super(ConstantThroughputTimer.class);
+ public ConstantThroughputTimerBeanInfo() {
+ super(ConstantThroughputTimer.class);
- ResourceBundle rb = (ResourceBundle) getBeanDescriptor().getValue(RESOURCE_BUNDLE);
+ ResourceBundle rb = (ResourceBundle) getBeanDescriptor().getValue(RESOURCE_BUNDLE);
// These must agree with the Timer resources
tags[0] = rb.getString("calcMode.1"); //$NON-NLS-1$
- tags[1] = rb.getString("calcMode.2"); //$NON-NLS-1$
- tags[2] = rb.getString("calcMode.3"); //$NON-NLS-1$
+ tags[1] = rb.getString("calcMode.2"); //$NON-NLS-1$
+ tags[2] = rb.getString("calcMode.3"); //$NON-NLS-1$
tags[3] = rb.getString("calcMode.4"); //$NON-NLS-1$
tags[4] = rb.getString("calcMode.5"); //$NON-NLS-1$
- createPropertyGroup("delay", //$NON-NLS-1$
+ createPropertyGroup("delay", //$NON-NLS-1$
new String[] { "throughput", //$NON-NLS-1$
"calcMode" }); //$NON-NLS-1$
- PropertyDescriptor p = property("throughput"); //$NON-NLS-1$
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, new Double(0.0));
-
- p = property("calcMode"); //$NON-NLS-1$
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, tags[0]);
- p.setValue(NOT_OTHER, Boolean.TRUE);
- p.setValue(NOT_EXPRESSION, Boolean.TRUE);
- p.setValue(TAGS, tags);
- }
-
- // TODO need to find better way to do this
- public static int getCalcModeAsInt(String mode) {
- for (int i = 0; i < tags.length; i++) {
- if (tags[i].equals(mode)) {
- return i;
- }
- }
- return -1;
- }
+ PropertyDescriptor p = property("throughput"); //$NON-NLS-1$
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, new Double(0.0));
+
+ p = property("calcMode"); //$NON-NLS-1$
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, tags[0]);
+ p.setValue(NOT_OTHER, Boolean.TRUE);
+ p.setValue(NOT_EXPRESSION, Boolean.TRUE);
+ p.setValue(TAGS, tags);
+ }
+
+ // TODO need to find better way to do this
+ public static int getCalcModeAsInt(String mode) {
+ for (int i = 0; i < tags.length; i++) {
+ if (tags[i].equals(mode)) {
+ return i;
+ }
+ }
+ return -1;
+ }
}
\ No newline at end of file
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/ConstantTimer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -28,80 +28,80 @@
/**
* This class implements a constant timer with its own panel and fields for
* value update and user interaction.
- *
+ *
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
*/
public class ConstantTimer extends AbstractTestElement implements Timer, Serializable, LoopIterationListener {
- public final static String DELAY = "ConstantTimer.delay"; //$NON-NLS-1$
+ public final static String DELAY = "ConstantTimer.delay"; //$NON-NLS-1$
- private long delay = 0;
+ private long delay = 0;
- /**
- * No-arg constructor.
- */
- public ConstantTimer() {
- }
-
- /**
- * Set the delay for this timer.
- *
- */
- public void setDelay(String delay) {
- setProperty(DELAY, delay);
- }
-
- /**
- * Set the range (not used for this timer).
- *
- */
- public void setRange(double range) {
- }
-
- /**
- * Get the delay value for display.
- *
- * @return the delay value for display.
- */
- public String getDelay() {
- return getPropertyAsString(DELAY);
- }
-
- /**
- * Retrieve the range (not used for this timer).
- *
- * @return the range (always zero for this timer).
- */
- public double getRange() {
- return 0;
- }
-
- /**
- * Retrieve the delay to use during test execution.
- *
- * @return the delay.
- */
- public long delay() {
- return delay;
- }
-
- /**
- * Provide a description of this timer class.
- *
- * @return the description of this timer class.
- */
- public String toString() {
- return JMeterUtils.getResString("constant_timer_memo"); //$NON-NLS-1$
- }
-
- /**
- * Gain access to any variables that have been defined.
- *
- * @see LoopIterationListener#iterationStart(LoopIterationEvent)
- */
- public void iterationStart(LoopIterationEvent event) {
- delay = getPropertyAsLong(DELAY);
+ /**
+ * No-arg constructor.
+ */
+ public ConstantTimer() {
+ }
+
+ /**
+ * Set the delay for this timer.
+ *
+ */
+ public void setDelay(String delay) {
+ setProperty(DELAY, delay);
+ }
+
+ /**
+ * Set the range (not used for this timer).
+ *
+ */
+ public void setRange(double range) {
+ }
+
+ /**
+ * Get the delay value for display.
+ *
+ * @return the delay value for display.
+ */
+ public String getDelay() {
+ return getPropertyAsString(DELAY);
+ }
+
+ /**
+ * Retrieve the range (not used for this timer).
+ *
+ * @return the range (always zero for this timer).
+ */
+ public double getRange() {
+ return 0;
+ }
+
+ /**
+ * Retrieve the delay to use during test execution.
+ *
+ * @return the delay.
+ */
+ public long delay() {
+ return delay;
+ }
+
+ /**
+ * Provide a description of this timer class.
+ *
+ * @return the description of this timer class.
+ */
+ public String toString() {
+ return JMeterUtils.getResString("constant_timer_memo"); //$NON-NLS-1$
+ }
+
+ /**
+ * Gain access to any variables that have been defined.
+ *
+ * @see LoopIterationListener#iterationStart(LoopIterationEvent)
+ */
+ public void iterationStart(LoopIterationEvent event) {
+ delay = getPropertyAsLong(DELAY);
- }
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/GaussianRandomTimer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -26,16 +26,16 @@
* This class implements those methods needed by RandomTimer to be instantiable
* and implements a random delay with an average value and a gaussian
* distributed variation.
- *
+ *
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
*/
public class GaussianRandomTimer extends RandomTimer implements Serializable {
- public long delay() {
- return (long) Math.abs((this.random.nextGaussian() * getRange()) + super.delay());
- }
+ public long delay() {
+ return (long) Math.abs((this.random.nextGaussian() * getRange()) + super.delay());
+ }
- public String toString() {
- return JMeterUtils.getResString("gaussian_timer_memo"); //$NON-NLS-1$
- }
+ public String toString() {
+ return JMeterUtils.getResString("gaussian_timer_memo"); //$NON-NLS-1$
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/RandomTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/RandomTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/RandomTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/RandomTimer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -28,41 +28,41 @@
* This class implements a random timer with its own panel and fields for value
* update and user interaction. Since this class does not define the delay()
* method, is abstract and must be extended to provide full functionality.
- *
+ *
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
* @version $Id$
*/
public abstract class RandomTimer extends ConstantTimer implements Timer, Serializable {
- public final static String RANGE = "RandomTimer.range";
+ public final static String RANGE = "RandomTimer.range";
- protected Random random;
+ protected Random random;
- /**
- * No-arg constructor.
- */
- public RandomTimer() {
- this.random = new Random();
- }
-
- /**
- * Set the range value.
- */
- public void setRange(double range) {
- setProperty(new DoubleProperty(RANGE, range));
- }
-
- public void setRange(String range) {
- setProperty(new StringProperty(RANGE, range));
- }
-
- /**
- * Get the range value.
- *
- * @return double
- */
- public double getRange() {
- return this.getPropertyAsDouble(RANGE);
- }
+ /**
+ * No-arg constructor.
+ */
+ public RandomTimer() {
+ this.random = new Random();
+ }
+
+ /**
+ * Set the range value.
+ */
+ public void setRange(double range) {
+ setProperty(new DoubleProperty(RANGE, range));
+ }
+
+ public void setRange(String range) {
+ setProperty(new StringProperty(RANGE, range));
+ }
+
+ /**
+ * Get the range value.
+ *
+ * @return double
+ */
+ public double getRange() {
+ return this.getPropertyAsDouble(RANGE);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimer.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -30,81 +30,81 @@
* The purpose of the SyncTimer is to block threads until X number of threads
* have been blocked, and then they are all released at once. A SyncTimer can
* thus create large instant loads at various points of the test plan.
- *
+ *
* @author mike
- *
+ *
*/
public class SyncTimer extends AbstractTestElement implements Timer, Serializable, TestBean {
- private static final long serialVersionUID = 2;
+ private static final long serialVersionUID = 2;
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
// Must be an Object so it will be shared between threads
- private int[] timerCounter = new int[] { 0 };
+ private int[] timerCounter = new int[] { 0 };
- private transient Object sync = new Object();
+ private transient Object sync = new Object();
- private int groupSize;
+ private int groupSize;
- // Ensure transient object is created by the server
- private Object readResolve(){
- sync = new Object();
- return this;
- }
-
- /**
- * @return Returns the numThreads.
- */
- public int getGroupSize() {
- return groupSize;
- }
-
- /**
- * @param numThreads
- * The numThreads to set.
- */
- public void setGroupSize(int numThreads) {
- this.groupSize = numThreads;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.timers.Timer#delay()
- */
- public long delay() {
- synchronized (sync) {
- timerCounter[0]++;
- final int groupSz = getGroupSize();
+ // Ensure transient object is created by the server
+ private Object readResolve(){
+ sync = new Object();
+ return this;
+ }
+
+ /**
+ * @return Returns the numThreads.
+ */
+ public int getGroupSize() {
+ return groupSize;
+ }
+
+ /**
+ * @param numThreads
+ * The numThreads to set.
+ */
+ public void setGroupSize(int numThreads) {
+ this.groupSize = numThreads;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.timers.Timer#delay()
+ */
+ public long delay() {
+ synchronized (sync) {
+ timerCounter[0]++;
+ final int groupSz = getGroupSize();
final int count = timerCounter[0];
if (
(groupSz == 0 && count >= JMeterContextService.getNumberOfThreads())
- ||
+ ||
(groupSz > 0 && count >= groupSz)
) {
- sync.notifyAll();
- } else {
- try {
- sync.wait();
- } catch (InterruptedException e) {
- log.warn(e.getLocalizedMessage());
- }
- }
+ sync.notifyAll();
+ } else {
+ try {
+ sync.wait();
+ } catch (InterruptedException e) {
+ log.warn(e.getLocalizedMessage());
+ }
+ }
timerCounter[0]=0; // Reset for next time
- }
- return 0;
- }
-
- /**
- * We have to control the cloning process because we need some cross-thread
- * communication if our synctimers are to be able to determine when to block
- * and when to release.
- */
- public Object clone() {
- SyncTimer newTimer = (SyncTimer) super.clone();
- newTimer.timerCounter = timerCounter;
- newTimer.sync = sync;
- return newTimer;
- }
+ }
+ return 0;
+ }
+
+ /**
+ * We have to control the cloning process because we need some cross-thread
+ * communication if our synctimers are to be able to determine when to block
+ * and when to release.
+ */
+ public Object clone() {
+ SyncTimer newTimer = (SyncTimer) super.clone();
+ newTimer.timerCounter = timerCounter;
+ newTimer.sync = sync;
+ return newTimer;
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/SyncTimerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -24,14 +24,14 @@
public class SyncTimerBeanInfo extends BeanInfoSupport {
- public SyncTimerBeanInfo() {
- super(SyncTimer.class);
+ public SyncTimerBeanInfo() {
+ super(SyncTimer.class);
- createPropertyGroup("grouping", new String[] { "groupSize" });
+ createPropertyGroup("grouping", new String[] { "groupSize" });
- PropertyDescriptor p = property("groupSize");
- p.setValue(NOT_UNDEFINED, Boolean.TRUE);
- p.setValue(DEFAULT, new Integer(0));
- }
+ PropertyDescriptor p = property("groupSize");
+ p.setValue(NOT_UNDEFINED, Boolean.TRUE);
+ p.setValue(DEFAULT, new Integer(0));
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/UniformRandomTimer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/UniformRandomTimer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/UniformRandomTimer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/UniformRandomTimer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers;
@@ -26,16 +26,16 @@
* This class implements those methods needed by RandomTimer to be instantiable
* and implements a random delay with an average value and a uniformly
* distributed variation.
- *
+ *
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
*/
public class UniformRandomTimer extends RandomTimer implements Serializable {
- public long delay() {
- return (long) Math.abs((this.random.nextDouble() * getRange()) + super.delay());
- }
-
- public String toString() {
- return JMeterUtils.getResString("uniform_timer_memo"); //$NON-NLS-1$
- }
+ public long delay() {
+ return (long) Math.abs((this.random.nextDouble() * getRange()) + super.delay());
+ }
+
+ public String toString() {
+ return JMeterUtils.getResString("uniform_timer_memo"); //$NON-NLS-1$
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/ConstantTimerGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers.gui;
@@ -31,99 +31,99 @@
/**
* The GUI for ConstantTimer.
- *
+ *
*/
public class ConstantTimerGui extends AbstractTimerGui {
- /**
- * The default value for the delay.
- */
- private static final String DEFAULT_DELAY = "300";
-
- private static final String DELAY_FIELD = "Delay Field";
-
- private JTextField delayField;
-
- /**
- * No-arg constructor.
- */
- public ConstantTimerGui() {
- init();
- }
-
- /**
- * Handle an error.
- *
- * @param e
- * the Exception that was thrown.
- * @param thrower
- * the JComponent that threw the Exception.
- */
- public static void error(Exception e, JComponent thrower) {
- JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- public String getLabelResource() {
- return "constant_timer_title"; // $NON-NLS-1$
- }
-
- /**
- * Create the test element underlying this GUI component.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- ConstantTimer timer = new ConstantTimer();
- modifyTestElement(timer);
- return timer;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement timer) {
- this.configureTestElement(timer);
- ((ConstantTimer) timer).setDelay(delayField.getText());
- }
-
- /**
- * Configure this GUI component from the underlying TestElement.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
- */
- public void configure(TestElement el) {
- super.configure(el);
- delayField.setText(((ConstantTimer) el).getDelay());
- }
-
- /**
- * Initialize this component.
- */
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
-
- setBorder(makeBorder());
- add(makeTitlePanel());
-
- Box delayPanel = Box.createHorizontalBox();
- JLabel delayLabel = new JLabel(JMeterUtils.getResString("constant_timer_delay"));//$NON-NLS-1$
- delayPanel.add(delayLabel);
-
- delayField = new JTextField(6);
- delayField.setText(DEFAULT_DELAY);
- delayField.setName(DELAY_FIELD);
- delayPanel.add(delayField);
- add(delayPanel);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
- */
- public void clearGui() {
- delayField.setText(DEFAULT_DELAY);
- super.clearGui();
- }
+ /**
+ * The default value for the delay.
+ */
+ private static final String DEFAULT_DELAY = "300";
+
+ private static final String DELAY_FIELD = "Delay Field";
+
+ private JTextField delayField;
+
+ /**
+ * No-arg constructor.
+ */
+ public ConstantTimerGui() {
+ init();
+ }
+
+ /**
+ * Handle an error.
+ *
+ * @param e
+ * the Exception that was thrown.
+ * @param thrower
+ * the JComponent that threw the Exception.
+ */
+ public static void error(Exception e, JComponent thrower) {
+ JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ public String getLabelResource() {
+ return "constant_timer_title"; // $NON-NLS-1$
+ }
+
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ ConstantTimer timer = new ConstantTimer();
+ modifyTestElement(timer);
+ return timer;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement timer) {
+ this.configureTestElement(timer);
+ ((ConstantTimer) timer).setDelay(delayField.getText());
+ }
+
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
+ public void configure(TestElement el) {
+ super.configure(el);
+ delayField.setText(((ConstantTimer) el).getDelay());
+ }
+
+ /**
+ * Initialize this component.
+ */
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH, VerticalLayout.TOP));
+
+ setBorder(makeBorder());
+ add(makeTitlePanel());
+
+ Box delayPanel = Box.createHorizontalBox();
+ JLabel delayLabel = new JLabel(JMeterUtils.getResString("constant_timer_delay"));//$NON-NLS-1$
+ delayPanel.add(delayLabel);
+
+ delayField = new JTextField(6);
+ delayField.setText(DEFAULT_DELAY);
+ delayField.setName(DELAY_FIELD);
+ delayPanel.add(delayField);
+ add(delayPanel);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
+ */
+ public void clearGui() {
+ delayField.setText(DEFAULT_DELAY);
+ super.clearGui();
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers.gui;
@@ -37,131 +37,131 @@
/**
* Implementation of a gaussian random timer.
- *
+ *
*/
public class GaussianRandomTimerGui extends AbstractTimerGui {
- private static final String DELAY_FIELD = "Delay Field";
+ private static final String DELAY_FIELD = "Delay Field";
- private static final String RANGE_FIELD = "Range Field";
+ private static final String RANGE_FIELD = "Range Field";
- private static final String DEFAULT_DELAY = "300"; // $NON-NLS-1$
+ private static final String DEFAULT_DELAY = "300"; // $NON-NLS-1$
- private static final String DEFAULT_RANGE = "100.0"; // $NON-NLS-1$
+ private static final String DEFAULT_RANGE = "100.0"; // $NON-NLS-1$
- private JTextField delayField;
-
- private JTextField rangeField;
-
- /**
- * No-arg constructor.
- */
- public GaussianRandomTimerGui() {
- init();
- }
-
- /**
- * Handle an error.
- *
- * @param e
- * the Exception that was thrown.
- * @param thrower
- * the JComponent that threw the Exception.
- */
- public static void error(Exception e, JComponent thrower) {
- JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- /**
- * Create the test element underlying this GUI component.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- RandomTimer timer = new GaussianRandomTimer();
- modifyTestElement(timer);
- return timer;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement timer) {
- this.configureTestElement(timer);
- ((RandomTimer) timer).setDelay(delayField.getText());
- ((RandomTimer) timer).setRange(rangeField.getText());
- }
-
- /**
- * Configure this GUI component from the underlying TestElement.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
- */
- public void configure(TestElement el) {
- super.configure(el);
- delayField.setText(el.getPropertyAsString(RandomTimer.DELAY));
- rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
- }
-
- public String getLabelResource() {
- return "gaussian_timer_title";//$NON-NLS-1$
- }
-
- /**
- * Initialize this component.
- */
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
- setBorder(makeBorder());
-
- add(makeTitlePanel());
-
- JPanel threadDelayPropsPanel = new JPanel();
- threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
- threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(
- JMeterUtils.getResString("thread_delay_properties")));//$NON-NLS-1$
-
- // DELAY DEVIATION
- Box delayDevPanel = Box.createHorizontalBox();
- delayDevPanel.add(new JLabel(JMeterUtils.getResString("gaussian_timer_range")));//$NON-NLS-1$
- delayDevPanel.add(Box.createHorizontalStrut(5));
-
- rangeField = new JTextField(6);
- rangeField.setText(DEFAULT_RANGE);
- rangeField.setName(RANGE_FIELD);
- delayDevPanel.add(rangeField);
-
- threadDelayPropsPanel.add(delayDevPanel);
-
- // AVG DELAY
- Box avgDelayPanel = Box.createHorizontalBox();
- avgDelayPanel.add(new JLabel(JMeterUtils.getResString("gaussian_timer_delay")));//$NON-NLS-1$
- avgDelayPanel.add(Box.createHorizontalStrut(5));
-
- delayField = new JTextField(6);
- delayField.setText(DEFAULT_DELAY);
- delayField.setName(DELAY_FIELD);
- avgDelayPanel.add(delayField);
-
- threadDelayPropsPanel.add(avgDelayPanel);
- threadDelayPropsPanel.setMaximumSize(new Dimension(threadDelayPropsPanel.getMaximumSize().width,
- threadDelayPropsPanel.getPreferredSize().height));
- add(threadDelayPropsPanel);
-
- // Set the initial focus to the delay field
- new FocusRequester(rangeField);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
- */
- public void clearGui() {
- rangeField.setText(DEFAULT_RANGE);
- delayField.setText(DEFAULT_DELAY);
- super.clearGui();
- }
+ private JTextField delayField;
+
+ private JTextField rangeField;
+
+ /**
+ * No-arg constructor.
+ */
+ public GaussianRandomTimerGui() {
+ init();
+ }
+
+ /**
+ * Handle an error.
+ *
+ * @param e
+ * the Exception that was thrown.
+ * @param thrower
+ * the JComponent that threw the Exception.
+ */
+ public static void error(Exception e, JComponent thrower) {
+ JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ RandomTimer timer = new GaussianRandomTimer();
+ modifyTestElement(timer);
+ return timer;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement timer) {
+ this.configureTestElement(timer);
+ ((RandomTimer) timer).setDelay(delayField.getText());
+ ((RandomTimer) timer).setRange(rangeField.getText());
+ }
+
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
+ public void configure(TestElement el) {
+ super.configure(el);
+ delayField.setText(el.getPropertyAsString(RandomTimer.DELAY));
+ rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
+ }
+
+ public String getLabelResource() {
+ return "gaussian_timer_title";//$NON-NLS-1$
+ }
+
+ /**
+ * Initialize this component.
+ */
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel());
+
+ JPanel threadDelayPropsPanel = new JPanel();
+ threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
+ threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(
+ JMeterUtils.getResString("thread_delay_properties")));//$NON-NLS-1$
+
+ // DELAY DEVIATION
+ Box delayDevPanel = Box.createHorizontalBox();
+ delayDevPanel.add(new JLabel(JMeterUtils.getResString("gaussian_timer_range")));//$NON-NLS-1$
+ delayDevPanel.add(Box.createHorizontalStrut(5));
+
+ rangeField = new JTextField(6);
+ rangeField.setText(DEFAULT_RANGE);
+ rangeField.setName(RANGE_FIELD);
+ delayDevPanel.add(rangeField);
+
+ threadDelayPropsPanel.add(delayDevPanel);
+
+ // AVG DELAY
+ Box avgDelayPanel = Box.createHorizontalBox();
+ avgDelayPanel.add(new JLabel(JMeterUtils.getResString("gaussian_timer_delay")));//$NON-NLS-1$
+ avgDelayPanel.add(Box.createHorizontalStrut(5));
+
+ delayField = new JTextField(6);
+ delayField.setText(DEFAULT_DELAY);
+ delayField.setName(DELAY_FIELD);
+ avgDelayPanel.add(delayField);
+
+ threadDelayPropsPanel.add(avgDelayPanel);
+ threadDelayPropsPanel.setMaximumSize(new Dimension(threadDelayPropsPanel.getMaximumSize().width,
+ threadDelayPropsPanel.getPreferredSize().height));
+ add(threadDelayPropsPanel);
+
+ // Set the initial focus to the delay field
+ new FocusRequester(rangeField);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
+ */
+ public void clearGui() {
+ rangeField.setText(DEFAULT_RANGE);
+ delayField.setText(DEFAULT_DELAY);
+ super.clearGui();
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/UniformRandomTimerGui.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.timers.gui;
@@ -35,132 +35,132 @@
/**
* Implementation of a uniform random timer.
- *
+ *
*/
public class UniformRandomTimerGui extends AbstractTimerGui {
- // TODO - are these gui item names needed?
- private static final String DELAY_FIELD = "Delay Field";
+ // TODO - are these gui item names needed?
+ private static final String DELAY_FIELD = "Delay Field";
- private static final String RANGE_FIELD = "Range Field";
+ private static final String RANGE_FIELD = "Range Field";
- private static final String DEFAULT_DELAY = "0"; // $NON-NLS-1$
+ private static final String DEFAULT_DELAY = "0"; // $NON-NLS-1$
- private static final String DEFAULT_RANGE = "100.0";// $NON-NLS-1$
+ private static final String DEFAULT_RANGE = "100.0";// $NON-NLS-1$
- private JTextField delayField;
-
- private JTextField rangeField;
-
- /**
- * No-arg constructor.
- */
- public UniformRandomTimerGui() {
- init();
- }
-
- /**
- * Handle an error.
- *
- * @param e
- * the Exception that was thrown.
- * @param thrower
- * the JComponent that threw the Exception.
- */
- public static void error(Exception e, JComponent thrower) {
- JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
- }
-
- public String getLabelResource() {
- return "uniform_timer_title"; //$NON-NLS-1$
- }
-
- /**
- * Create the test element underlying this GUI component.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
- */
- public TestElement createTestElement() {
- RandomTimer timer = new UniformRandomTimer();
- modifyTestElement(timer);
- return timer;
- }
-
- /**
- * Modifies a given TestElement to mirror the data in the gui components.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
- */
- public void modifyTestElement(TestElement timer) {
- this.configureTestElement(timer);
- ((RandomTimer) timer).setDelay(delayField.getText());
- ((RandomTimer) timer).setRange(rangeField.getText());
- }
-
- /**
- * Configure this GUI component from the underlying TestElement.
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
- */
- public void configure(TestElement el) {
- super.configure(el);
- delayField.setText(el.getPropertyAsString(RandomTimer.DELAY));
- rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
- }
-
- /**
- * Initialize this component.
- */
- private void init() {
- setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
- setBorder(makeBorder());
-
- add(makeTitlePanel());
-
- // THREAD DELAY PROPERTIES
- JPanel threadDelayPropsPanel = new JPanel();
- threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
- threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils
- .getResString("thread_delay_properties"))); //$NON-NLS-1$
-
- // DELAY DEVIATION
- Box delayDevPanel = Box.createHorizontalBox();
- delayDevPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_range"))); //$NON-NLS-1$
- delayDevPanel.add(Box.createHorizontalStrut(5));
-
- rangeField = new JTextField(6);
- rangeField.setText(DEFAULT_RANGE);
- rangeField.setName(RANGE_FIELD);
- delayDevPanel.add(rangeField);
-
- threadDelayPropsPanel.add(delayDevPanel);
-
- // AVG DELAY
- Box avgDelayPanel = Box.createHorizontalBox();
- avgDelayPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_delay"))); //$NON-NLS-1$
- avgDelayPanel.add(Box.createHorizontalStrut(5));
-
- delayField = new JTextField(6);
- delayField.setText(DEFAULT_DELAY);
- delayField.setName(DELAY_FIELD);
- avgDelayPanel.add(delayField);
-
- threadDelayPropsPanel.add(avgDelayPanel);
-
- add(threadDelayPropsPanel);
-
- // Set the initial focus to the range field
- new FocusRequester(rangeField);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
- */
- public void clearGui() {
- rangeField.setText(DEFAULT_RANGE);
- delayField.setText(DEFAULT_DELAY);
- super.clearGui();
- }
+ private JTextField delayField;
+
+ private JTextField rangeField;
+
+ /**
+ * No-arg constructor.
+ */
+ public UniformRandomTimerGui() {
+ init();
+ }
+
+ /**
+ * Handle an error.
+ *
+ * @param e
+ * the Exception that was thrown.
+ * @param thrower
+ * the JComponent that threw the Exception.
+ */
+ public static void error(Exception e, JComponent thrower) {
+ JOptionPane.showMessageDialog(thrower, e, "Error", JOptionPane.ERROR_MESSAGE);
+ }
+
+ public String getLabelResource() {
+ return "uniform_timer_title"; //$NON-NLS-1$
+ }
+
+ /**
+ * Create the test element underlying this GUI component.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#createTestElement()
+ */
+ public TestElement createTestElement() {
+ RandomTimer timer = new UniformRandomTimer();
+ modifyTestElement(timer);
+ return timer;
+ }
+
+ /**
+ * Modifies a given TestElement to mirror the data in the gui components.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#modifyTestElement(TestElement)
+ */
+ public void modifyTestElement(TestElement timer) {
+ this.configureTestElement(timer);
+ ((RandomTimer) timer).setDelay(delayField.getText());
+ ((RandomTimer) timer).setRange(rangeField.getText());
+ }
+
+ /**
+ * Configure this GUI component from the underlying TestElement.
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#configure(TestElement)
+ */
+ public void configure(TestElement el) {
+ super.configure(el);
+ delayField.setText(el.getPropertyAsString(RandomTimer.DELAY));
+ rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
+ }
+
+ /**
+ * Initialize this component.
+ */
+ private void init() {
+ setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
+ setBorder(makeBorder());
+
+ add(makeTitlePanel());
+
+ // THREAD DELAY PROPERTIES
+ JPanel threadDelayPropsPanel = new JPanel();
+ threadDelayPropsPanel.setLayout(new VerticalLayout(5, VerticalLayout.LEFT));
+ threadDelayPropsPanel.setBorder(BorderFactory.createTitledBorder(JMeterUtils
+ .getResString("thread_delay_properties"))); //$NON-NLS-1$
+
+ // DELAY DEVIATION
+ Box delayDevPanel = Box.createHorizontalBox();
+ delayDevPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_range"))); //$NON-NLS-1$
+ delayDevPanel.add(Box.createHorizontalStrut(5));
+
+ rangeField = new JTextField(6);
+ rangeField.setText(DEFAULT_RANGE);
+ rangeField.setName(RANGE_FIELD);
+ delayDevPanel.add(rangeField);
+
+ threadDelayPropsPanel.add(delayDevPanel);
+
+ // AVG DELAY
+ Box avgDelayPanel = Box.createHorizontalBox();
+ avgDelayPanel.add(new JLabel(JMeterUtils.getResString("uniform_timer_delay"))); //$NON-NLS-1$
+ avgDelayPanel.add(Box.createHorizontalStrut(5));
+
+ delayField = new JTextField(6);
+ delayField.setText(DEFAULT_DELAY);
+ delayField.setName(DELAY_FIELD);
+ avgDelayPanel.add(delayField);
+
+ threadDelayPropsPanel.add(avgDelayPanel);
+
+ add(threadDelayPropsPanel);
+
+ // Set the initial focus to the range field
+ new FocusRequester(rangeField);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jmeter.gui.JMeterGUIComponent#clearGui()
+ */
+ public void clearGui() {
+ rangeField.setText(DEFAULT_RANGE);
+ delayField.setText(DEFAULT_DELAY);
+ super.clearGui();
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AccumListener.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AccumListener.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AccumListener.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AccumListener.java Sun Jul 6 14:47:12 2008
@@ -13,12 +13,12 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
public interface AccumListener {
- public void updateGui(RunningSample s);
+ public void updateGui(RunningSample s);
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AssertionVisualizer.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -36,77 +36,77 @@
public class AssertionVisualizer extends AbstractVisualizer implements Clearable {
- private JTextArea textArea;
+ private JTextArea textArea;
- public AssertionVisualizer() {
- init();
- setName(getStaticLabel());
- }
-
- public String getLabelResource() {
- return "assertion_visualizer_title"; // $NON-NLS-1$
- }
-
- public void add(SampleResult sample) {
- StringBuffer sb = new StringBuffer(100);
- sb.append(sample.getSampleLabel());
- sb.append(getAssertionResult(sample));
- sb.append("\n"); // $NON-NLS-1$
- synchronized (textArea) {
- textArea.append(sb.toString());
- }
- }
-
- public void clearData() {
- textArea.setText(""); // $NON-NLS-1$
- }
-
- private String getAssertionResult(SampleResult res) {
- if (res != null) {
- StringBuffer display = new StringBuffer();
- AssertionResult assertionResults[] = res.getAssertionResults();
- for (int i = 0; i < assertionResults.length; i++) {
- AssertionResult item = assertionResults[i];
-
- if (item.isFailure() || item.isError()) {
- display.append("\n\t"); // $NON-NLS-1$
- display.append(item.getName() != null ? item.getName() + " : " : "");// $NON-NLS-1$
- display.append(item.getFailureMessage());
- }
- }
- return display.toString();
- }
- return "";
- }
-
- private void init() {
- this.setLayout(new BorderLayout());
-
- // MAIN PANEL
- Border margin = new EmptyBorder(10, 10, 5, 10);
+ public AssertionVisualizer() {
+ init();
+ setName(getStaticLabel());
+ }
+
+ public String getLabelResource() {
+ return "assertion_visualizer_title"; // $NON-NLS-1$
+ }
+
+ public void add(SampleResult sample) {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(sample.getSampleLabel());
+ sb.append(getAssertionResult(sample));
+ sb.append("\n"); // $NON-NLS-1$
+ synchronized (textArea) {
+ textArea.append(sb.toString());
+ }
+ }
+
+ public void clearData() {
+ textArea.setText(""); // $NON-NLS-1$
+ }
+
+ private String getAssertionResult(SampleResult res) {
+ if (res != null) {
+ StringBuffer display = new StringBuffer();
+ AssertionResult assertionResults[] = res.getAssertionResults();
+ for (int i = 0; i < assertionResults.length; i++) {
+ AssertionResult item = assertionResults[i];
+
+ if (item.isFailure() || item.isError()) {
+ display.append("\n\t"); // $NON-NLS-1$
+ display.append(item.getName() != null ? item.getName() + " : " : "");// $NON-NLS-1$
+ display.append(item.getFailureMessage());
+ }
+ }
+ return display.toString();
+ }
+ return "";
+ }
+
+ private void init() {
+ this.setLayout(new BorderLayout());
+
+ // MAIN PANEL
+ Border margin = new EmptyBorder(10, 10, 5, 10);
- this.setBorder(margin);
+ this.setBorder(margin);
- // NAME
- this.add(makeTitlePanel(), BorderLayout.NORTH);
+ // NAME
+ this.add(makeTitlePanel(), BorderLayout.NORTH);
- // TEXTAREA LABEL
- JLabel textAreaLabel =
+ // TEXTAREA LABEL
+ JLabel textAreaLabel =
new JLabel(JMeterUtils.getResString("assertion_textarea_label")); // $NON-NLS-1$
- Box mainPanel = Box.createVerticalBox();
- mainPanel.add(textAreaLabel);
+ Box mainPanel = Box.createVerticalBox();
+ mainPanel.add(textAreaLabel);
- // TEXTAREA
- textArea = new JTextArea();
- textArea.setEditable(false);
- textArea.setLineWrap(false);
- JScrollPane areaScrollPane = new JScrollPane(textArea);
+ // TEXTAREA
+ textArea = new JTextArea();
+ textArea.setEditable(false);
+ textArea.setLineWrap(false);
+ JScrollPane areaScrollPane = new JScrollPane(textArea);
- areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- areaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ areaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
areaScrollPane.setPreferredSize(new Dimension(mainPanel.getWidth(),mainPanel.getHeight()));
- mainPanel.add(areaScrollPane);
- this.add(mainPanel, BorderLayout.CENTER);
- }
+ mainPanel.add(areaScrollPane);
+ this.add(mainPanel, BorderLayout.CENTER);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/AxisGraph.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -51,75 +51,75 @@
*/
public class AxisGraph extends JPanel {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggingManager.getLoggerForClass();
private static final String ELLIPSIS = "..."; //$NON-NLS-1$
- private static final int ELLIPSIS_LEN = ELLIPSIS.length();
-
+ private static final int ELLIPSIS_LEN = ELLIPSIS.length();
+
protected double[][] data = null;
protected String title, xAxisTitle, yAxisTitle, yAxisLabel;
protected int maxLength;
protected String[] xAxisLabels;
protected int width, height;
-
- /**
- *
- */
- public AxisGraph() {
- super();
- }
-
- /**
- * @param layout
- */
- public AxisGraph(LayoutManager layout) {
- super(layout);
- }
-
- /**
- * @param layout
- * @param isDoubleBuffered
- */
- public AxisGraph(LayoutManager layout, boolean isDoubleBuffered) {
- super(layout, isDoubleBuffered);
- }
-
+
+ /**
+ *
+ */
+ public AxisGraph() {
+ super();
+ }
+
+ /**
+ * @param layout
+ */
+ public AxisGraph(LayoutManager layout) {
+ super(layout);
+ }
+
+ /**
+ * @param layout
+ * @param isDoubleBuffered
+ */
+ public AxisGraph(LayoutManager layout, boolean isDoubleBuffered) {
+ super(layout, isDoubleBuffered);
+ }
+
public void setData(double[][] data) {
this.data = data;
}
-
+
public void setTitle(String title) {
this.title = title;
}
public void setMaxLength(int maxLength) {
this.maxLength = maxLength;
- }
-
+ }
+
public void setXAxisTitle(String title) {
this.xAxisTitle = title;
}
-
+
public void setYAxisTitle(String title) {
this.yAxisTitle = title;
}
-
+
public void setXAxisLabels(String[] labels) {
this.xAxisLabels = labels;
}
-
+
public void setYAxisLabels(String label) {
this.yAxisLabel = label;
}
-
+
public void setWidth(int w) {
this.width = w;
}
-
+
public void setHeight(int h) {
this.height = h;
}
-
+
public void paintComponent(Graphics g) {
if (data != null && this.title != null && this.xAxisLabels != null &&
this.xAxisTitle != null && this.yAxisLabel != null &&
@@ -141,7 +141,7 @@
}
return max;
}
-
+
private String squeeze (String input, int _maxLength){
if (input.length()>_maxLength){
String output=input.substring(0,_maxLength-ELLIPSIS_LEN)+ELLIPSIS;
@@ -149,7 +149,7 @@
}
return input;
}
-
+
private void drawSample(String _title, int _maxLength, String[] _xAxisLabels, String _xAxisTitle,
String _yAxisTitle, double[][] _data, int _width, int _height, Graphics g) {
double max = findMax(_data);
@@ -161,7 +161,7 @@
if (_height == 0) {
_height = 250;
}
- **/
+ **/
if (_maxLength < 3) {
_maxLength = 3;
}
@@ -176,7 +176,7 @@
}
this.setPreferredSize(new Dimension(_width,_height));
DataSeries dataSeries = new DataSeries( _xAxisLabels, _xAxisTitle, _yAxisTitle, _title );
-
+
String[] legendLabels= { yAxisLabel };
Paint[] paints= new Paint[] { Color.yellow };
BarChartProperties barChartProperties= new BarChartProperties();
@@ -203,12 +203,12 @@
} catch (PropertyException e) {
log.warn("",e);
}
-
+
AxisProperties axisProperties= new AxisProperties(xaxis, yaxis);
axisProperties.setXAxisLabelsAreVertical(true);
LegendProperties legendProperties= new LegendProperties();
- AxisChart axisChart = new AxisChart(
- dataSeries, chartProperties, axisProperties,
+ AxisChart axisChart = new AxisChart(
+ dataSeries, chartProperties, axisProperties,
legendProperties, _width, _height );
axisChart.setGraphics2D((Graphics2D) g);
axisChart.render();
@@ -218,5 +218,5 @@
log.warn("",e);
}
}
-
+
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BSFListenerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BSFListenerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BSFListenerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BSFListenerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -22,8 +22,8 @@
public class BSFListenerBeanInfo extends BSFBeanInfoSupport {
- public BSFListenerBeanInfo() {
- super(BSFListener.class);
- }
+ public BSFListenerBeanInfo() {
+ super(BSFListener.class);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListener.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListener.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListener.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListener.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -32,13 +32,13 @@
import org.apache.jorphan.util.JMeterException;
import org.apache.log.Logger;
-public class BeanShellListener extends BeanShellTestElement
+public class BeanShellListener extends BeanShellTestElement
implements Cloneable, SampleListener, TestBean, Visualizer, UnsharedComponent {
- // N.B. Needs to implement Visualizer so that TestBeanGUI can find the correct GUI class
- // TODO - remove UnsharedComponent ? Probably does not make sense for a TestBean.
-
+ // N.B. Needs to implement Visualizer so that TestBeanGUI can find the correct GUI class
+ // TODO - remove UnsharedComponent ? Probably does not make sense for a TestBean.
+
private static final Logger log = LoggingManager.getLoggerForClass();
-
+
private static final long serialVersionUID = 4;
// can be specified in jmeter.properties
@@ -48,13 +48,13 @@
return INIT_FILE;
}
- public void sampleOccurred(SampleEvent se) {
+ public void sampleOccurred(SampleEvent se) {
final BeanShellInterpreter bshInterpreter = getBeanShellInterpreter();
- if (bshInterpreter == null) {
+ if (bshInterpreter == null) {
log.error("BeanShell not found");
return;
}
-
+
JMeterContext jmctx = JMeterContextService.getContext();
JMeterVariables vars = jmctx.getVariables();
SampleResult samp=se.getResult();
@@ -67,22 +67,22 @@
processFileOrScript(bshInterpreter);
} catch (JMeterException e) {
log.warn("Problem in BeanShell script "+e);
- }
- }
+ }
+ }
- public void sampleStarted(SampleEvent e) {
- }
+ public void sampleStarted(SampleEvent e) {
+ }
- public void sampleStopped(SampleEvent e) {
- }
+ public void sampleStopped(SampleEvent e) {
+ }
+
+ public void add(SampleResult sample) {
+ // TODO Auto-generated method stub
- public void add(SampleResult sample) {
- // TODO Auto-generated method stub
-
- }
-
- public boolean isStats() { // Needed by Visualizer interface
- return false;
- }
+ }
+
+ public boolean isStats() { // Needed by Visualizer interface
+ return false;
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListenerBeanInfo.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListenerBeanInfo.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListenerBeanInfo.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/BeanShellListenerBeanInfo.java Sun Jul 6 14:47:12 2008
@@ -5,15 +5,15 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -22,8 +22,8 @@
public class BeanShellListenerBeanInfo extends BeanShellBeanInfoSupport {
- public BeanShellListenerBeanInfo() {
- super(BeanShellListener.class);
- }
+ public BeanShellListenerBeanInfo() {
+ super(BeanShellListener.class);
+ }
}
Modified: jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/DistributionGraph.java
URL: http://svn.apache.org/viewvc/jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/DistributionGraph.java?rev=674351&r1=674350&r2=674351&view=diff
==============================================================================
--- jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/DistributionGraph.java (original)
+++ jakarta/jmeter/trunk/src/components/org/apache/jmeter/visualizers/DistributionGraph.java Sun Jul 6 14:47:12 2008
@@ -13,7 +13,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
*/
package org.apache.jmeter.visualizers;
@@ -41,169 +41,169 @@
* general, the data will tend to clump in predictable ways when the application
* is well designed and implemented. Data that generates erratic graphs are
* generally not desirable.
- *
+ *
*/
public class DistributionGraph extends JComponent implements Scrollable, Clearable {
- private SamplingStatCalculator model;
+ private SamplingStatCalculator model;
- private final int xborder = 30;
+ private final int xborder = 30;
- /**
- * Constructor for the Graph object.
- */
- public DistributionGraph() {
- init();
- }
-
- /**
- * Constructor for the Graph object.
- */
- public DistributionGraph(SamplingStatCalculator model) {
- this();
- setModel(model);
- }
-
- private void init() {// called from ctor, so must not be overridable
- repaint();
- }
-
- /**
- * Gets the ScrollableTracksViewportWidth attribute of the Graph object.
- *
- * @return the ScrollableTracksViewportWidth value
- */
- public boolean getScrollableTracksViewportWidth() {
- return true;
- }
-
- /**
- * Gets the ScrollableTracksViewportHeight attribute of the Graph object.
- *
- * @return the ScrollableTracksViewportHeight value
- */
- public boolean getScrollableTracksViewportHeight() {
- return true;
- }
-
- /**
- * Sets the Model attribute of the Graph object.
- */
- private void setModel(Object model) {
- this.model = (SamplingStatCalculator) model;
- repaint();
- }
-
- /**
- * Gets the PreferredScrollableViewportSize attribute of the Graph object.
- *
- * @return the PreferredScrollableViewportSize value
- */
- public Dimension getPreferredScrollableViewportSize() {
- return this.getPreferredSize();
- }
-
- /**
- * Gets the ScrollableUnitIncrement attribute of the Graph object.
- *
- * @return the ScrollableUnitIncrement value
- */
- public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
- return 5;
- }
-
- /**
- * Gets the ScrollableBlockIncrement attribute of the Graph object.
- *
- * @return the ScrollableBlockIncrement value
- */
- public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
- return (int) (visibleRect.width * .9);
- }
-
- /**
- * Clears this graph.
- */
- public void clearData() {
- model.clear();
- }
-
- /**
- * Method is responsible for calling drawSample and updating the graph.
- */
- public void paintComponent(Graphics g) {
- super.paintComponent(g);
- final SamplingStatCalculator m = this.model;
- synchronized (m) {
- drawSample(m, g);
- }
- }
-
- private void drawSample(SamplingStatCalculator p_model, Graphics g) {
- int width = getWidth();
- double height = getHeight() - 1.0;
-
- // first lets draw the grid
- for (int y = 0; y < 4; y++) {
- int q1 = (int) (height - (height * 0.25 * y));
- g.setColor(Color.lightGray);
- g.drawLine(xborder, q1, width, q1);
- g.setColor(Color.black);
- g.drawString(String.valueOf((25 * y) + "%"), 0, q1);
- }
- g.setColor(Color.black);
- // draw the X axis
- g.drawLine(xborder, (int) height, width, (int) height);
- // draw the Y axis
- g.drawLine(xborder, 0, xborder, (int) height);
- // the test plan has to have more than 200 samples
- // for it to generate half way decent distribution
- // graph. the larger the sample, the better the
- // results.
- if (p_model != null && p_model.getCount() > 50) {
- // now draw the bar chart
- Number ninety = p_model.getPercentPoint(0.90);
- Number fifty = p_model.getPercentPoint(0.50);
-
- int total = p_model.getCount();
- Collection values = p_model.getDistribution().values();
- Object[] objval = new Object[values.size()];
- objval = values.toArray(objval);
- // we sort the objects
- Arrays.sort(objval, new NumberComparator());
- int len = objval.length;
- for (int count = 0; count < len; count++) {
- // calculate the height
- Number[] num = (Number[]) objval[count];
- double iper = (double) num[1].intValue() / (double) total;
- double iheight = height * iper;
- // if the height is less than one, we set it
- // to one pixel
- if (iheight < 1) {
- iheight = 1.0;
- }
- int ix = (count * 4) + xborder + 5;
- int dheight = (int) (height - iheight);
- g.setColor(Color.blue);
- g.drawLine(ix - 1, (int) height, ix - 1, dheight);
- g.drawLine(ix, (int) height, ix, dheight);
- g.setColor(Color.black);
- // draw a red line for 90% point
- if (num[0].longValue() == ninety.longValue()) {
- g.setColor(Color.red);
- g.drawLine(ix, (int) height, ix, 55);
- g.drawLine(ix, 35, ix, 0);
- g.drawString("90%", ix - 30, 20);
- g.drawString(String.valueOf(num[0].longValue()), ix + 8, 20);
- }
- // draw an orange line for 50% point
- if (num[0].longValue() == fifty.longValue()) {
- g.setColor(Color.orange);
- g.drawLine(ix, (int) height, ix, 30);
- g.drawString("50%", ix - 30, 50);
- g.drawString(String.valueOf(num[0].longValue()), ix + 8, 50);
- }
- }
- }
- }
+ /**
+ * Constructor for the Graph object.
+ */
+ public DistributionGraph() {
+ init();
+ }
+
+ /**
+ * Constructor for the Graph object.
+ */
+ public DistributionGraph(SamplingStatCalculator model) {
+ this();
+ setModel(model);
+ }
+
+ private void init() {// called from ctor, so must not be overridable
+ repaint();
+ }
+
+ /**
+ * Gets the ScrollableTracksViewportWidth attribute of the Graph object.
+ *
+ * @return the ScrollableTracksViewportWidth value
+ */
+ public boolean getScrollableTracksViewportWidth() {
+ return true;
+ }
+
+ /**
+ * Gets the ScrollableTracksViewportHeight attribute of the Graph object.
+ *
+ * @return the ScrollableTracksViewportHeight value
+ */
+ public boolean getScrollableTracksViewportHeight() {
+ return true;
+ }
+
+ /**
+ * Sets the Model attribute of the Graph object.
+ */
+ private void setModel(Object model) {
+ this.model = (SamplingStatCalculator) model;
+ repaint();
+ }
+
+ /**
+ * Gets the PreferredScrollableViewportSize attribute of the Graph object.
+ *
+ * @return the PreferredScrollableViewportSize value
+ */
+ public Dimension getPreferredScrollableViewportSize() {
+ return this.getPreferredSize();
+ }
+
+ /**
+ * Gets the ScrollableUnitIncrement attribute of the Graph object.
+ *
+ * @return the ScrollableUnitIncrement value
+ */
+ public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
+ return 5;
+ }
+
+ /**
+ * Gets the ScrollableBlockIncrement attribute of the Graph object.
+ *
+ * @return the ScrollableBlockIncrement value
+ */
+ public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
+ return (int) (visibleRect.width * .9);
+ }
+
+ /**
+ * Clears this graph.
+ */
+ public void clearData() {
+ model.clear();
+ }
+
+ /**
+ * Method is responsible for calling drawSample and updating the graph.
+ */
+ public void paintComponent(Graphics g) {
+ super.paintComponent(g);
+ final SamplingStatCalculator m = this.model;
+ synchronized (m) {
+ drawSample(m, g);
+ }
+ }
+
+ private void drawSample(SamplingStatCalculator p_model, Graphics g) {
+ int width = getWidth();
+ double height = getHeight() - 1.0;
+
+ // first lets draw the grid
+ for (int y = 0; y < 4; y++) {
+ int q1 = (int) (height - (height * 0.25 * y));
+ g.setColor(Color.lightGray);
+ g.drawLine(xborder, q1, width, q1);
+ g.setColor(Color.black);
+ g.drawString(String.valueOf((25 * y) + "%"), 0, q1);
+ }
+ g.setColor(Color.black);
+ // draw the X axis
+ g.drawLine(xborder, (int) height, width, (int) height);
+ // draw the Y axis
+ g.drawLine(xborder, 0, xborder, (int) height);
+ // the test plan has to have more than 200 samples
+ // for it to generate half way decent distribution
+ // graph. the larger the sample, the better the
+ // results.
+ if (p_model != null && p_model.getCount() > 50) {
+ // now draw the bar chart
+ Number ninety = p_model.getPercentPoint(0.90);
+ Number fifty = p_model.getPercentPoint(0.50);
+
+ int total = p_model.getCount();
+ Collection values = p_model.getDistribution().values();
+ Object[] objval = new Object[values.size()];
+ objval = values.toArray(objval);
+ // we sort the objects
+ Arrays.sort(objval, new NumberComparator());
+ int len = objval.length;
+ for (int count = 0; count < len; count++) {
+ // calculate the height
+ Number[] num = (Number[]) objval[count];
+ double iper = (double) num[1].intValue() / (double) total;
+ double iheight = height * iper;
+ // if the height is less than one, we set it
+ // to one pixel
+ if (iheight < 1) {
+ iheight = 1.0;
+ }
+ int ix = (count * 4) + xborder + 5;
+ int dheight = (int) (height - iheight);
+ g.setColor(Color.blue);
+ g.drawLine(ix - 1, (int) height, ix - 1, dheight);
+ g.drawLine(ix, (int) height, ix, dheight);
+ g.setColor(Color.black);
+ // draw a red line for 90% point
+ if (num[0].longValue() == ninety.longValue()) {
+ g.setColor(Color.red);
+ g.drawLine(ix, (int) height, ix, 55);
+ g.drawLine(ix, 35, ix, 0);
+ g.drawString("90%", ix - 30, 20);
+ g.drawString(String.valueOf(num[0].longValue()), ix + 8, 20);
+ }
+ // draw an orange line for 50% point
+ if (num[0].longValue() == fifty.longValue()) {
+ g.setColor(Color.orange);
+ g.drawLine(ix, (int) height, ix, 30);
+ g.drawString("50%", ix - 30, 50);
+ g.drawString(String.valueOf(num[0].longValue()), ix + 8, 50);
+ }
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org