| java.lang.Object javolution.context.Context javolution.context.LogContext javolution.testing.TestContext javolution.testing.TimeContext
TimeContext | abstract public class TimeContext extends TestContext (Code) | | This class represents a
TestContext test context specialized
for measuring execution time.
TimeContext implementations may perform assertions based upon the
execution time. For example:[code]
class MyTestCase extends TestCase() {
...
public void validate() {
long ns = TimeContext.getAverageTime("ns");
TimeContext.assertTrue(ns < 100); // Error if execution time is more than 100 ns.
...
}
}[/code]
author: Jean-Marie Dautelle version: 5.2, August 5, 2007 |
Field Summary | |
final public static Configurable | DEFAULT Holds the time context default implementation (by default logs
average and minimum execution time to System.out ). | final public static Class | REGRESSION Holds an implementation which does not perform any logging but raises an
AssertionException when an assertion fails, including any timing
assertion. | final public static Configurable | TEST_DURATION_MS Holds the minimum duration of each test case execution (default 2000 ms). |
DEFAULT | final public static Configurable DEFAULT(Code) | | Holds the time context default implementation (by default logs
average and minimum execution time to System.out ).
|
REGRESSION | final public static Class REGRESSION(Code) | | Holds an implementation which does not perform any logging but raises an
AssertionException when an assertion fails, including any timing
assertion.
|
TEST_DURATION_MS | final public static Configurable TEST_DURATION_MS(Code) | | Holds the minimum duration of each test case execution (default 2000 ms).
The larger the number the more accurate is the average time result; but
the longer it takes to run the test.
|
exit | public static Context exit()(Code) | | Exits the current time context.
the time context being exited. throws: ClassCastException - if the context is not a stack context. |
getAverageTime | public static long getAverageTime(String unit)(Code) | | Returns the average execution time of the latest execution performed or
-1 if the current context is not a time context.
Parameters: unit - one of "s", "ms", "us", "ns", "ps" the average execution time stated in the specified unit. |
getAverageTimeInPicoSeconds | public long getAverageTimeInPicoSeconds()(Code) | | Returns the average execution time of the latest execution stated in
pico-seconds.
the time in pico-seconds. |
getMaximumTime | public static long getMaximumTime(String unit)(Code) | | Returns the maximum execution time of the latest execution performed or
-1 if the current context is not a time context.
Parameters: unit - one of "s", "ms", "us", "ns", "ps" the maximum execution time stated in the specified unit. |
getMaximumTimeInPicoSeconds | public long getMaximumTimeInPicoSeconds()(Code) | | Returns the maximmum execution time of the latest execution stated in
pico-seconds.
the time in pico-seconds. |
getMinimumTime | public static long getMinimumTime(String unit)(Code) | | Returns the minimum execution time of the latest execution performed or
-1 if the current context is not a time context.
Parameters: unit - one of "s", "ms", "us", "ns", "ps" the minimum execution time stated in the specified unit. |
getMinimumTimeInPicoSeconds | public long getMinimumTimeInPicoSeconds()(Code) | | Returns the minimum execution time of the latest execution stated in
pico-seconds.
the time in pico-seconds. |
|
|