jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1634699 - /jmeter/trunk/src/core/org/apache/jmeter/control/RunTime.java
Date Wed, 29 Oct 2014 18:58:20 GMT
On 27 October 2014 22:05,  <pmouawad@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
>
>

Mime
View raw message