Package spock.config
Class ParallelConfiguration
- java.lang.Object
-
- spock.config.ParallelConfiguration
-
public class ParallelConfiguration extends Object
-
-
Field Summary
Fields Modifier and Type Field Description org.spockframework.runtime.model.parallel.ExecutionMode
defaultExecutionMode
org.spockframework.runtime.model.parallel.ExecutionMode
defaultSpecificationExecutionMode
boolean
enabled
-
Constructor Summary
Constructors Constructor Description ParallelConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
custom(int parallelism, int minimumRunnable, int maxPoolSize, int corePoolSize, int keepAliveSeconds)
Allows fine grained custom control over the parameters of the execution.void
dynamic(BigDecimal factor)
Computes the desired parallelism based on the number of available processors/cores multiplied by thefactor
.void
dynamicWithReservedProcessors(BigDecimal factor, int reservedProcessors)
Computes the desired parallelism based on the number of available processors multiplied by thefactor
however it makes sure to keepreservedProcessors
free.void
fixed(int parallelism)
Uses a fixed value forparallelism
.org.spockframework.runtime.DefaultParallelExecutionConfiguration
getParallelExecutionConfiguration()
Internal use only
-
-
-
Method Detail
-
dynamic
public void dynamic(BigDecimal factor)
Computes the desired parallelism based on the number of available processors/cores multiplied by thefactor
.- Parameters:
factor
- to use to determine parallelism
-
dynamicWithReservedProcessors
public void dynamicWithReservedProcessors(BigDecimal factor, int reservedProcessors)
Computes the desired parallelism based on the number of available processors multiplied by thefactor
however it makes sure to keepreservedProcessors
free.Example:
Given a configuration of
dynamicWithReservedProcessors(1, 2)
On a system with 8 threads 6 threads will be used for testing. On a system with 4 threads only 2 threads will be used for testing. On a system with 1 or 2 threads only 1 thread will be used for testing, effectively deactivating parallel execution.- Parameters:
factor
- to use to determine parallelism (must be<= 1
)reservedProcessors
- the number for processors to reserve for other things (must be>= 0
)
-
fixed
public void fixed(int parallelism)
Uses a fixed value forparallelism
.- Parameters:
parallelism
- the parallelism level
-
custom
public void custom(int parallelism, int minimumRunnable, int maxPoolSize, int corePoolSize, int keepAliveSeconds)
Allows fine grained custom control over the parameters of the execution.- Parameters:
parallelism
- the parallelism levelminimumRunnable
- the minimum allowed number of core threads not blocked by a join orManagedBlocker
. To ensure progress, when too few unblocked threads exist and unexecuted tasks may exist, new threads are constructed, up to the given maximumPoolSize. For the default value, use1
, that ensures liveness. A larger value might improve throughput in the presence of blocked activities, but might not, due to increased overhead. A value of zero may be acceptable when submitted tasks cannot have dependencies requiring additional threads.maxPoolSize
- the maximum number of threads allowed. When the maximum is reached, attempts to replace blocked threads fail. (However, because creation and termination of different threads may overlap, and may be managed by the given thread factory, this value may be transiently exceeded.) To arrange the same value as is used by default for the common pool, use256
plus theparallelism
level. (By default, the common pool allows a maximum of 256 spare threads.) Using a value (for exampleInteger.MAX_VALUE
) larger than the implementation's total thread limit has the same effect as using this limit (which is the default).corePoolSize
- the number of threads to keep in the pool (unless timed out after an elapsed keep-alive). Normally (and by default) this is the same value as the parallelism level, but may be set to a larger value to reduce dynamic overhead if tasks regularly block. Using a smaller value (for example0
) has the same effect as the default.keepAliveSeconds
- the elapsed time since last use before a thread is terminated (and then later replaced if needed).
-
getParallelExecutionConfiguration
public org.spockframework.runtime.DefaultParallelExecutionConfiguration getParallelExecutionConfiguration()
Internal use only- Returns:
- ParallelExecutionConfiguration
-
-