On 29 October 2014 20:04, Philippe Mouawad <[email protected]> wrote: > Hello Sebb, > Please compare with revision 1595401 > I think code is fine currently > > Original code was: > return System.currentTimeMillis() - startTime >= 1000 * > getRuntime(); > > and in next(): > if (startTime == 0) { > startTime = System.currentTimeMillis(); > } > > Now startTime is in nano > (System.nanoTime() - startTime) is in nano > ((System.nanoTime() - startTime)/1000000.0) is in ms to be compared with > 1000 * getRuntime() as getRuntime is in ms;
Actually, getRuntime() is in seconds However I agree that division by 10^6 converts nano-seconds to milliseconds, so the calculation is correct after all. Sorry for the noise about that. > > On Wed, Oct 29, 2014 at 7:58 PM, sebb <[email protected]> wrote: > >> On 27 October 2014 22:05, <[email protected]> wrote: >> > Author: pmouawad >> > Date: Mon Oct 27 22:05:54 2014 >> > New Revision: 1634699 >> > >> > URL: http://svn.apache.org/r1634699 >> > Log: >> > Oups wrong conversion >> >> -1 >> >> > >> > Modified: >> > jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java >> > >> > Modified: jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java >> > URL: >> http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java?rev=1634699&r1=1634698&r2=1634699&view=diff >> > >> ============================================================================== >> > --- jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java >> (original) >> > +++ jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java Mon Oct >> 27 22:05:54 2014 >> > @@ -72,7 +72,7 @@ public class RunTime extends GenericCont >> > } >> > >> > private boolean endOfLoop() { >> > - return ((System.nanoTime() - startTime)/1000) >= 1000 * >> getRuntime(); >> > + return ((System.nanoTime() - startTime)/1000000.0) >= 1000 * >> getRuntime(); >> >> That looks wrong on several counts. >> getRuntime() is in seconds. >> >> The original code was >> return System.currentTimeMillis() - startTime >= 1000 * getRuntime(); >> >> i.e. it compared the elapsed time using milliseconds. >> >> Also it's not efficient to perform arithmetic on both sides of the >> comparison >> >> I think the code should be >> >> return ((System.nanoTime() - startTime)/1000000L) >= getRuntime(); >> >> Or one could use >> >> return (System.nanoTime() - startTime) >= 1000000L * getRuntime(); >> >> but that is more likely to overflow. >> >> >> >> >> > } >> > >> > @Override >> > >> > >> > > > > -- > Cordialement. > Philippe Mouawad.
