jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1226250 - in /jmeter/trunk: src/components/org/apache/jmeter/timers/ src/components/org/apache/jmeter/timers/gui/ src/core/org/apache/jmeter/resources/ xdocs/
Date Sun, 01 Jan 2012 14:15:22 GMT
Author: pmouawad
Date: Sun Jan  1 14:15:21 2012
New Revision: 1226250

URL: http://svn.apache.org/viewvc?rev=1226250&view=rev
Log:
Bug 37073 - Add a Poisson based timer
Factored GaussianRandomTimerGui and PoissonRandomTimerGui

Added:
    jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java   (with props)
    jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java 
 (with props)
    jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java  
(with props)
Modified:
    jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
    jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
    jmeter/trunk/xdocs/changes.xml

Added: jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java?rev=1226250&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java Sun Jan 
1 14:15:21 2012
@@ -0,0 +1,390 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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;
+
+import java.io.Serializable;
+
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * This class implements those methods needed by RandomTimer to be instantiable
+ * and implements a random delay with an average value and a Poisson
+ * distributed variation.
+ *
+ */
+public class PoissonRandomTimer extends RandomTimer implements Serializable {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3514708226113231004L;
+	/**
+	 * 
+	 */
+	private static final double[] LOG_FACTORIAL = 
+        {
+            0.000000000000000,
+            0.000000000000000,
+            0.693147180559945,
+            1.791759469228055,
+            3.178053830347946,
+            4.787491742782046,
+            6.579251212010101,
+            8.525161361065415,
+            10.604602902745251,
+            12.801827480081469,
+            15.104412573075516,
+            17.502307845873887,
+            19.987214495661885,
+            22.552163853123421,
+            25.191221182738683,
+            27.899271383840894,
+            30.671860106080675,
+            33.505073450136891,
+            36.395445208033053,
+            39.339884187199495,
+            42.335616460753485,
+            45.380138898476908,
+            48.471181351835227,
+            51.606675567764377,
+            54.784729398112319,
+            58.003605222980518,
+            61.261701761002001,
+            64.557538627006323,
+            67.889743137181526,
+            71.257038967168000,
+            74.658236348830158,
+            78.092223553315307,
+            81.557959456115029,
+            85.054467017581516,
+            88.580827542197682,
+            92.136175603687079,
+            95.719694542143202,
+            99.330612454787428,
+            102.968198614513810,
+            106.631760260643450,
+            110.320639714757390,
+            114.034211781461690,
+            117.771881399745060,
+            121.533081515438640,
+            125.317271149356880,
+            129.123933639127240,
+            132.952575035616290,
+            136.802722637326350,
+            140.673923648234250,
+            144.565743946344900,
+            148.477766951773020,
+            152.409592584497350,
+            156.360836303078800,
+            160.331128216630930,
+            164.320112263195170,
+            168.327445448427650,
+            172.352797139162820,
+            176.395848406997370,
+            180.456291417543780,
+            184.533828861449510,
+            188.628173423671600,
+            192.739047287844900,
+            196.866181672889980,
+            201.009316399281570,
+            205.168199482641200,
+            209.342586752536820,
+            213.532241494563270,
+            217.736934113954250,
+            221.956441819130360,
+            226.190548323727570,
+            230.439043565776930,
+            234.701723442818260,
+            238.978389561834350,
+            243.268849002982730,
+            247.572914096186910,
+            251.890402209723190,
+            256.221135550009480,
+            260.564940971863220,
+            264.921649798552780,
+            269.291097651019810,
+            273.673124285693690,
+            278.067573440366120,
+            282.474292687630400,
+            286.893133295426990,
+            291.323950094270290,
+            295.766601350760600,
+            300.220948647014100,
+            304.686856765668720,
+            309.164193580146900,
+            313.652829949878990,
+            318.152639620209300,
+            322.663499126726210,
+            327.185287703775200,
+            331.717887196928470,
+            336.261181979198450,
+            340.815058870798960,
+            345.379407062266860,
+            349.954118040770250,
+            354.539085519440790,
+            359.134205369575340,
+            363.739375555563470,
+            368.354496072404690,
+            372.979468885689020,
+            377.614197873918670,
+            382.258588773060010,
+            386.912549123217560,
+            391.575988217329610,
+            396.248817051791490,
+            400.930948278915760,
+            405.622296161144900,
+            410.322776526937280,
+            415.032306728249580,
+            419.750805599544780,
+            424.478193418257090,
+            429.214391866651570,
+            433.959323995014870,
+            438.712914186121170,
+            443.475088120918940,
+            448.245772745384610,
+            453.024896238496130,
+            457.812387981278110,
+            462.608178526874890,
+            467.412199571608080,
+            472.224383926980520,
+            477.044665492585580,
+            481.872979229887900,
+            486.709261136839360,
+            491.553448223298010,
+            496.405478487217580,
+            501.265290891579240,
+            506.132825342034830,
+            511.008022665236070,
+            515.890824587822520,
+            520.781173716044240,
+            525.679013515995050,
+            530.584288294433580,
+            535.496943180169520,
+            540.416924105997740,
+            545.344177791154950,
+            550.278651724285620,
+            555.220294146894960,
+            560.169054037273100,
+            565.124881094874350,
+            570.087725725134190,
+            575.057539024710200,
+            580.034272767130800,
+            585.017879388839220,
+            590.008311975617860,
+            595.005524249382010,
+            600.009470555327430,
+            605.020105849423770,
+            610.037385686238740,
+            615.061266207084940,
+            620.091704128477430,
+            625.128656730891070,
+            630.172081847810200,
+            635.221937855059760,
+            640.278183660408100,
+            645.340778693435030,
+            650.409682895655240,
+            655.484856710889060,
+            660.566261075873510,
+            665.653857411105950,
+            670.747607611912710,
+            675.847474039736880,
+            680.953419513637530,
+            686.065407301994010,
+            691.183401114410800,
+            696.307365093814040,
+            701.437263808737160,
+            706.573062245787470,
+            711.714725802289990,
+            716.862220279103440,
+            722.015511873601330,
+            727.174567172815840,
+            732.339353146739310,
+            737.509837141777440,
+            742.685986874351220,
+            747.867770424643370,
+            753.055156230484160,
+            758.248113081374300,
+            763.446610112640200,
+            768.650616799717000,
+            773.860102952558460,
+            779.075038710167410,
+            784.295394535245690,
+            789.521141208958970,
+            794.752249825813460,
+            799.988691788643450,
+            805.230438803703120,
+            810.477462875863580,
+            815.729736303910160,
+            820.987231675937890,
+            826.249921864842800,
+            831.517780023906310,
+            836.790779582469900,
+            842.068894241700490,
+            847.352097970438420,
+            852.640365001133090,
+            857.933669825857460,
+            863.231987192405430,
+            868.535292100464630,
+            873.843559797865740,
+            879.156765776907600,
+            884.474885770751830,
+            889.797895749890240,
+            895.125771918679900,
+            900.458490711945270,
+            905.796028791646340,
+            911.138363043611210,
+            916.485470574328820,
+            921.837328707804890,
+            927.193914982476710,
+            932.555207148186240,
+            937.921183163208070,
+            943.291821191335660,
+            948.667099599019820,
+            954.046996952560450,
+            959.431492015349480,
+            964.820563745165940,
+            970.214191291518320,
+            975.612353993036210,
+            981.015031374908400,
+            986.422203146368590,
+            991.833849198223450,
+            997.249949600427840,
+            1002.670484599700300,
+            1008.095434617181700,
+            1013.524780246136200,
+            1018.958502249690200,
+            1024.396581558613400,
+            1029.838999269135500,
+            1035.285736640801600,
+            1040.736775094367400,
+            1046.192096209724900,
+            1051.651681723869200,
+            1057.115513528895000,
+            1062.583573670030100,
+            1068.055844343701400,
+            1073.532307895632800,
+            1079.012946818975000,
+            1084.497743752465600,
+            1089.986681478622400,
+            1095.479742921962700,
+            1100.976911147256000,
+            1106.478169357800900,
+            1111.983500893733000,
+            1117.492889230361000,
+            1123.006317976526100,
+            1128.523770872990800,
+            1134.045231790853000,
+            1139.570684729984800,
+            1145.100113817496100,
+            1150.633503306223700,
+            1156.170837573242400,
+        };
+	
+
+	/**
+	 * {@inheritDoc}
+	 */
+    @Override
+    public long delay() {
+        return Math.abs(randomPoisson((int)Math.round(getRange())) + super.delay());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString() {
+        return JMeterUtils.getResString("poisson_timer_memo"); //$NON-NLS-1$
+    }
+    
+    /**
+     * Generate Poisson random based using 
+     * @param lambda Lambda in Poisson
+     * @return random
+     */
+    private static int randomPoisson(int lambda) {
+    	if(lambda <= 30) {
+    		return poissonRandomNumberLowEq30(lambda);
+    	} else {
+    		return poissonRandomNumberSup30(lambda);
+    	}
+    }
+	/**
+	 * see http://en.wikipedia.org/wiki/Poisson_distribution
+     * @param lambda Lambda in Poisson
+     * @return random
+	 */
+	private static final int poissonRandomNumberLowEq30(int lambda) {
+		double L = Math.exp(-lambda);
+		int k = 0;
+		double p = 1;
+		do {
+			k = k + 1;
+			double u = Math.random();
+			p = p * u;
+		} while (p > L);
+		return k - 1;
+	}
+	
+	/**
+	 * http://www.johndcook.com/blog/2010/06/14/generating-poisson-random-values/
+     * @param lambda Lambda in Poisson
+     * @return random
+	 */
+	private static final int poissonRandomNumberSup30(int lambda) {
+		double c = 0.767 - 3.36/lambda;
+		double beta = Math.PI/Math.sqrt(3.0*lambda);
+		double alpha = beta*lambda;
+		double k = Math.log(c) - lambda - Math.log(beta);
+		while(true) {
+			double u = Math.random();
+			double x = (alpha - Math.log((1.0 - u)/u))/beta;
+			int n = (int)Math.floor(x + 0.5);
+			if (n < 0){
+				continue;
+			}
+			double v = Math.random();
+			double y = alpha - beta*x;
+			double lhs = y + Math.log(v/Math.pow((1.0 + Math.exp(y)),2));
+			double rhs = k + n*Math.log(lambda) -logFactorial(n);
+			if (lhs <= rhs) {
+				return n;
+			}
+		}
+	}
+	
+	/**
+	 * Compute log factorial
+	 * http://www.johndcook.com/blog/2010/08/16/how-to-compute-log-factorial/
+	 * @param n Number for which we want log(n!)
+	 * @return Log factorial
+	 */
+	private static final double logFactorial(int n)
+    {
+        if (n < 0) {
+            throw new IllegalArgumentException();
+        }
+        else if (n > 254) {
+            double x = n + 1;
+            return (x - 0.5)*Math.log(x) - x + 0.5*Math.log(2*Math.PI) + 1.0/(12.0*x);
+        }
+        else {   
+            return LOG_FACTORIAL[n];
+        }
+    }
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/timers/PoissonRandomTimer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java?rev=1226250&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java Sun
Jan  1 14:15:21 2012
@@ -0,0 +1,196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.gui;
+
+import java.awt.Dimension;
+
+import javax.swing.BorderFactory;
+import javax.swing.Box;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+
+import org.apache.jmeter.gui.util.FocusRequester;
+import org.apache.jmeter.testelement.TestElement;
+import org.apache.jmeter.timers.ConstantTimer;
+import org.apache.jmeter.timers.RandomTimer;
+import org.apache.jmeter.util.JMeterUtils;
+import org.apache.jorphan.gui.layout.VerticalLayout;
+
+/**
+ * Abstract Random timer GUI.
+ *
+ */
+public abstract class AbstractRandomTimerGui extends AbstractTimerGui {
+
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = -322164502276145504L;
+
+	private static final String DELAY_FIELD = "Delay Field";
+
+    private static final String RANGE_FIELD = "Range Field";
+
+    private JTextField delayField;
+
+    private JTextField rangeField;
+
+    /**
+     * No-arg constructor.
+     */
+    public AbstractRandomTimerGui() {
+        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 = createRandomTimer();
+        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)
+     */
+    @Override
+    public void configure(TestElement el) {
+        super.configure(el);
+        delayField.setText(el.getPropertyAsString(ConstantTimer.DELAY));
+        rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
+    }
+
+    
+    /**
+     * 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(getTimerRangeLabelKey()));//$NON-NLS-1$
+        delayDevPanel.add(Box.createHorizontalStrut(5));
+
+        rangeField = new JTextField(6);
+        rangeField.setText(getDefaultRange());
+        rangeField.setName(RANGE_FIELD);
+        delayDevPanel.add(rangeField);
+
+        threadDelayPropsPanel.add(delayDevPanel);
+
+        // AVG DELAY
+        Box avgDelayPanel = Box.createHorizontalBox();
+        avgDelayPanel.add(new JLabel(getTimerDelayLabelKey()));//$NON-NLS-1$
+        avgDelayPanel.add(Box.createHorizontalStrut(5));
+
+        delayField = new JTextField(6);
+        delayField.setText(getDefaultDelay());
+        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);
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void clearGui() {
+        rangeField.setText(getDefaultRange());
+        delayField.setText(getDefaultDelay());
+        super.clearGui();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    abstract public String getLabelResource();
+
+    /**
+     * Create implementation of RandomTimer
+     * @return {@link RandomTimer} 
+     */
+    protected abstract RandomTimer createRandomTimer();
+
+    /**
+     * @return String timer delay label key
+     */
+    abstract protected String getTimerDelayLabelKey();
+
+    /**
+     * @return String timer range label key
+     */
+    abstract protected String getTimerRangeLabelKey();
+
+    /**
+     * @return String default delay value
+     */
+    abstract protected String getDefaultDelay();
+
+    /**
+     * @return String default range value
+     */
+    abstract protected String getDefaultRange();
+}
\ No newline at end of file

Propchange: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/AbstractRandomTimerGui.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java?rev=1226250&r1=1226249&r2=1226250&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/gui/GaussianRandomTimerGui.java Sun
Jan  1 14:15:21 2012
@@ -18,153 +18,74 @@
 
 package org.apache.jmeter.timers.gui;
 
-import java.awt.Dimension;
-
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import org.apache.jmeter.gui.util.FocusRequester;
-import org.apache.jmeter.testelement.TestElement;
-import org.apache.jmeter.timers.ConstantTimer;
 import org.apache.jmeter.timers.GaussianRandomTimer;
 import org.apache.jmeter.timers.RandomTimer;
 import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.gui.layout.VerticalLayout;
 
 /**
  * Implementation of a gaussian random timer.
- *
  */
-public class GaussianRandomTimerGui extends AbstractTimerGui {
+public class GaussianRandomTimerGui extends AbstractRandomTimerGui {
 
     private static final long serialVersionUID = 240L;
 
-    private static final String DELAY_FIELD = "Delay Field";
-
-    private static final String RANGE_FIELD = "Range Field";
-
     private static final String DEFAULT_DELAY = "300"; // $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);
+        super();
     }
 
     /**
-     * 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)
+     * {@inheritDoc}
      */
     @Override
-    public void configure(TestElement el) {
-        super.configure(el);
-        delayField.setText(el.getPropertyAsString(ConstantTimer.DELAY));
-        rangeField.setText(el.getPropertyAsString(RandomTimer.RANGE));
-    }
-
     public String getLabelResource() {
         return "gaussian_timer_title";//$NON-NLS-1$
     }
 
     /**
-     * Initialize this component.
+     * {@inheritDoc}
      */
-    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);
+	@Override
+	protected RandomTimer createRandomTimer() {
+		return new GaussianRandomTimer();
+	}
 
-        // Set the initial focus to the delay field
-        new FocusRequester(rangeField);
-    }
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getTimerDelayLabelKey() {
+		return JMeterUtils.getResString("gaussian_timer_delay");
+	}
 
-    /**
+	/**
      * {@inheritDoc}
      */
-    @Override
-    public void clearGui() {
-        rangeField.setText(DEFAULT_RANGE);
-        delayField.setText(DEFAULT_DELAY);
-        super.clearGui();
-    }
-}
+	@Override
+	protected String getTimerRangeLabelKey() {
+		return JMeterUtils.getResString("gaussian_timer_range");
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getDefaultDelay() {
+		return DEFAULT_DELAY;
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getDefaultRange() {
+		return DEFAULT_RANGE;
+	}
+}
\ No newline at end of file

Added: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java?rev=1226250&view=auto
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java (added)
+++ jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java Sun
Jan  1 14:15:21 2012
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.gui;
+
+import org.apache.jmeter.timers.PoissonRandomTimer;
+import org.apache.jmeter.timers.RandomTimer;
+import org.apache.jmeter.util.JMeterUtils;
+
+/**
+ * Implementation of a Poisson random timer.
+ */
+public class PoissonRandomTimerGui extends AbstractRandomTimerGui {
+
+    /**
+	 * 
+	 */
+	private static final long serialVersionUID = -3218002787832805275L;
+
+	private static final String DEFAULT_DELAY = "300"; // $NON-NLS-1$
+
+    private static final String DEFAULT_RANGE = "100"; // $NON-NLS-1$
+
+    /**
+     * No-arg constructor.
+     */
+    public PoissonRandomTimerGui() {
+        super();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String getLabelResource() {
+        return "poisson_timer_title";//$NON-NLS-1$
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+	@Override
+	protected RandomTimer createRandomTimer() {
+		return new PoissonRandomTimer();
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getTimerDelayLabelKey() {
+		return JMeterUtils.getResString("poisson_timer_delay");
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getTimerRangeLabelKey() {
+		return JMeterUtils.getResString("poisson_timer_range");
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getDefaultDelay() {
+		return DEFAULT_DELAY;
+	}
+
+	/**
+     * {@inheritDoc}
+     */
+	@Override
+	protected String getDefaultRange() {
+		return DEFAULT_RANGE;
+	}
+}

Propchange: jmeter/trunk/src/components/org/apache/jmeter/timers/gui/PoissonRandomTimerGui.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties?rev=1226250&r1=1226249&r2=1226250&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages.properties Sun Jan  1 14:15:21
2012
@@ -573,6 +573,10 @@ patterns_to_exclude=URL Patterns to Excl
 patterns_to_include=URL Patterns to Include
 pkcs12_desc=PKCS 12 Key (*.p12)
 pl=Polish
+poisson_timer_delay=Constant Delay Offset (in milliseconds)\:
+poisson_timer_memo=Adds a random delay with a poisson distribution
+poisson_timer_range=Deviation (in milliseconds)\:
+poisson_timer_title=Poisson Timer
 port=Port\:
 post_as_parameters=Parameters
 post_as_rawbody=RAW Body

Modified: jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties?rev=1226250&r1=1226249&r2=1226250&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/resources/messages_fr.properties Sun Jan  1 14:15:21
2012
@@ -255,7 +255,7 @@ functional_mode=Mode de test fonctionnel
 functional_mode_explanation=S\u00E9lectionner le mode de test fonctionnel uniquement si vous
avez besoin\nd'enregistrer les donn\u00E9es re\u00E7ues du serveur dans un fichier \u00E0
chaque requ\u00EAte. \n\nS\u00E9lectionner cette option affecte consid\u00E9rablement les
performances.
 gaussian_timer_delay=D\u00E9lai de d\u00E9calage bas\u00E9 gaussian (en millisecondes) \:
 gaussian_timer_memo=Ajoute un d\u00E9lai al\u00E9atoire avec une distribution gaussienne
-gaussian_timer_range=D\u00E9calage (en millisecondes) \:
+gaussian_timer_range=D\u00E9viation (en millisecondes) \:
 gaussian_timer_title=Compteur de temps al\u00E9atoire gaussien
 generate=G\u00E9n\u00E9rer
 generator=Nom de la classe g\u00E9n\u00E9ratrice
@@ -567,6 +567,10 @@ patterns_to_exclude=URL \: motifs \u00E0
 patterns_to_include=URL \: motifs \u00E0 inclure
 pkcs12_desc=Clef PKCS 12 (*.p12)
 pl=Polonais
+poisson_timer_delay=D\u00E9lai de d\u00E9calage bas\u00E9 sur la loi de poisson (en millisecondes)
\:
+poisson_timer_memo=Ajoute un d\u00E9lai al\u00E9atoire avec une distribution de type Poisson
+poisson_timer_range=D\u00E9viation (en millisecondes) \:
+poisson_timer_title=Compteur de temps al\u00E9atoire selon la loi de Poisson 
 port=Port \:
 post_as_parameters=Param\u00E8tres
 post_as_rawbody=Donn\u00E9es brutes
@@ -951,7 +955,7 @@ unescape_html_string=Cha\u00EEne \u00E0 
 unescape_string=Cha\u00EEne de caract\u00E8res contenant des\u00E9chappements Java
 uniform_timer_delay=D\u00E9lai de d\u00E9calage constant (en millisecondes) \:
 uniform_timer_memo=Ajoute un d\u00E9lai al\u00E9atoire avec une distribution uniforme
-uniform_timer_range=D\u00E9lai al\u00E9atoire maximum (en millisecondes) \:
+uniform_timer_range=D\u00E9viation al\u00E9atoire maximum (en millisecondes) \:
 uniform_timer_title=Compteur de temps al\u00E9atoire uniforme
 up=Monter
 update_per_iter=Mettre \u00E0 jour une fois par it\u00E9ration

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1226250&r1=1226249&r2=1226250&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Jan  1 14:15:21 2012
@@ -202,6 +202,7 @@ This behaviour can be changed with prope
 <li>Bug 52128 - Add JDBC pre- and post-processor</li>
 <li>Bug 52183 - SyncTimer could be improved (performance+reliability)</li>
 <li>Bug 52317 - Counter : Add option to reset counter on each Thread Group iteration</li>
+<li>Bug 37073 - Add a Poisson based timer</li>
 </ul>
 
 <h3>Functions</h3>



Mime
View raw message