You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by sebb <se...@gmail.com> on 2014/10/29 19:58:20 UTC
Re: svn commit: r1634699 - /jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java
On 27 October 2014 22:05, <pm...@apache.org> 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
>
>
Re: svn commit: r1634699 - /jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java
Posted by sebb <se...@gmail.com>.
On 29 October 2014 20:04, Philippe Mouawad <ph...@gmail.com> 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 <se...@gmail.com> wrote:
>
>> On 27 October 2014 22:05, <pm...@apache.org> 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.
Re: svn commit: r1634699 - /jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java
Posted by Philippe Mouawad <ph...@gmail.com>.
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;
On Wed, Oct 29, 2014 at 7:58 PM, sebb <se...@gmail.com> wrote:
> On 27 October 2014 22:05, <pm...@apache.org> 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.