net.grinder.testutility
Class Time

java.lang.Object
  extended by net.grinder.testutility.Time

public abstract class Time
extends Object

Abstract base class which times a method and returns whether it executed within the given range.

Author:
Philip Aston

Field Summary
static long J2SE_TIME_ACCURACY_MILLIS
          We slacken assertions about time to account for precision of J2SE time API.
 
Constructor Summary
Time(long expectedMin, long expectedMax)
           
 
Method Summary
abstract  void doIt()
           
 boolean run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

J2SE_TIME_ACCURACY_MILLIS

public static final long J2SE_TIME_ACCURACY_MILLIS
We slacken assertions about time to account for precision of J2SE time API. On JRockit 1.4.2_10 and a Dell 520, I've seen this code: final long t1 = System.currentTimeMillis(); Thread.sleep(50); System.out.println(System.currentTimeMillis()-t1); print out "47". I've repeated this with Thread.sleep(50, 0). Javadoc for System.currentTimeMillis() mentions its inaccuracy, and I think it's this method rather than Thread.sleep() that's so slack. Can't use System.nanoTime() as we can't assume J2SE 1.5. Value obtained empirically.

See Also:
Constant Field Values
Constructor Detail

Time

public Time(long expectedMin,
            long expectedMax)
Method Detail

doIt

public abstract void doIt()
                   throws Exception
Throws:
Exception

run

public boolean run()
            throws Exception
Throws:
Exception


Copyright © 2000-2012. All Rights Reserved.