Package randoop.util
Class ReflectionExecutor
- java.lang.Object
-
- randoop.util.ReflectionExecutor
-
public final class ReflectionExecutor extends Object
Static methods that executes the code of a ReflectionCode object.This class maintains an "executor" thread. Code is executed on that thread. If the code takes longer than the specified timeout, the thread is killed and a TimeoutException exception is reported.
-
-
Field Summary
Fields Modifier and Type Field Description static int
call_timeout
After this many milliseconds, a non-returning method call, and its associated test, are stopped forcefully.static int
CALL_TIMEOUT_MILLIS_DEFAULT
Default for call_timeout, in milliseconds.private static int
excep_exec_count
The number of exceptional executions.private static long
excep_exec_duration_nanos
The sum of durations for exceptional executions, in nanoseconds.private static int
normal_exec_count
The number of normal executions.private static long
normal_exec_duration_nanos
The sum of durations for normal executions, in nanoseconds.static boolean
usethreads
If true, Randoop executes each test in a separate thread and kills tests that take too long to finish, as determined by the --call-timeout command-line argument.
-
Constructor Summary
Constructors Modifier Constructor Description private
ReflectionExecutor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
excepExecAvgMillis()
The average exceptional execution time, in milliseconds.static int
excepExecs()
static ExecutionOutcome
executeReflectionCode(ReflectionCode code)
Executescode.runReflectionCode()
, which setscode
'sReflectionCode.retval
orReflectionCode.exceptionThrown
field.private static void
executeReflectionCodeThreaded(ReflectionCode code)
Executes code.runReflectionCode() in its own thread.private static void
executeReflectionCodeUnThreaded(ReflectionCode code)
Executes code.runReflectionCode() in the current thread.static double
normalExecAvgMillis()
The average normal execution time, in milliseconds.static int
normalExecs()
static void
resetStatistics()
Set statistics about normal and exceptional executions to zero.
-
-
-
Field Detail
-
usethreads
public static boolean usethreads
If true, Randoop executes each test in a separate thread and kills tests that take too long to finish, as determined by the --call-timeout command-line argument. Tests killed in this manner are not reported to the user, but are recorded in Randoop's log. Use the--log
command-line option to make Randoop produce the log.Use this option if Randoop does not terminate, which is usually due to execution of code under test that results in an infinite loop or that waits for user input. The downside of this option is a BIG (order-of-magnitude) decrease in generation speed. The tests are not run in parallel, merely in isolation.
-
CALL_TIMEOUT_MILLIS_DEFAULT
public static int CALL_TIMEOUT_MILLIS_DEFAULT
Default for call_timeout, in milliseconds. Should only be accessed bycheckOptionsValid()
.
-
call_timeout
public static int call_timeout
After this many milliseconds, a non-returning method call, and its associated test, are stopped forcefully. Only meaningful if--usethreads
is also specified.
-
normal_exec_duration_nanos
private static long normal_exec_duration_nanos
The sum of durations for normal executions, in nanoseconds.
-
normal_exec_count
private static int normal_exec_count
The number of normal executions.
-
excep_exec_duration_nanos
private static long excep_exec_duration_nanos
The sum of durations for exceptional executions, in nanoseconds.
-
excep_exec_count
private static int excep_exec_count
The number of exceptional executions.
-
-
Method Detail
-
resetStatistics
public static void resetStatistics()
Set statistics about normal and exceptional executions to zero.
-
normalExecs
public static int normalExecs()
-
excepExecs
public static int excepExecs()
-
normalExecAvgMillis
public static double normalExecAvgMillis()
The average normal execution time, in milliseconds.
-
excepExecAvgMillis
public static double excepExecAvgMillis()
The average exceptional execution time, in milliseconds.
-
executeReflectionCode
public static ExecutionOutcome executeReflectionCode(ReflectionCode code)
Executescode.runReflectionCode()
, which setscode
'sReflectionCode.retval
orReflectionCode.exceptionThrown
field.- Parameters:
code
- theReflectionCode
to be executed- Returns:
- the execution result
-
executeReflectionCodeThreaded
private static void executeReflectionCodeThreaded(ReflectionCode code) throws TimeoutException
Executes code.runReflectionCode() in its own thread.- Parameters:
code
- theReflectionCode
to be executed- Throws:
TimeoutException
- if execution times out
-
executeReflectionCodeUnThreaded
private static void executeReflectionCodeUnThreaded(ReflectionCode code)
Executes code.runReflectionCode() in the current thread.- Parameters:
code
- theReflectionCode
to be executed
-
-