-
Notifications
You must be signed in to change notification settings - Fork 9
Peass Execution Model (iterations repetitions and BeforeAll BeforeEach AfterEach AfterAll)
Since the time function introduces noise and is time-consuming itself, Peass executes the workload inside of a given count of repetitions
. Before and after all repetitions, a measurement is done; afterwards, only the time of the execution of repetitions
executions of the workload is saved. This execution is first done warmup
times for the warmup iterations; their measurement values are discarded. Afterwards, the executions are done iteration
times for the measurement iterations. The resulting values are saved.
This is repeated vms
times for both versions.
For the measurement of tests, the following order is currently applied:
-
@BeforeClass
/@BeforeAll
methods are called - For each iteration:
-
@BeforeNoMeasurement
is executed - Repetition start time is recorded
- For each repetition
-
@BeforeWithMeasurement
is executed -
@Before
/@BeforeEach
is executed - Test method itself is executed
-
@After
/@AfterEach
is executed -
@AfterWithMeasurement
is executed
-
- Repetition end time is recorded
-
@AfterNoMeasurement
is executed -
@AfterClass
/@AfterEach
is executed
Since Peass automatically transforms your tests, @BeforeNoMeasurement
and @AfterNoMeasurement
will most likely not be present in your code.
This can be configured by two parameters:
-
executeBeforeClassInMeasurement
causes@BeforeClass
/@BeforeAll
to be transformed into@BeforeWithMeasurement
, so it is executed every repetition -
onlyMeasureWorkload
causes time measurement to be done directly at the method, so before and after are not measured at all. This is not compatible withexecuteBeforeClassInMeasurement
.
Mocking creates some challenges for Peass, since the mocked objects are created in the code and are not allowed to be created twice.
There are generally two ways to handle this situation:
- Creating and initializing the mocked objects only once: Initialize your mock objects using
private static final MyMockType myMockObject = Mockito.mock(MyMockType.class);
, configure them in@BeforeAll
(using e.g.Mockito.when(...)
) and setexecuteBeforeClassInMeasurement
to false (default, but it requires a suitable initialization of your mocks). - Creating and initializing the mocked objects in every repetition:
Mockito.mock(MyMockType.class)
and is called in every repetition. Since mocked objects should only be initialized and configured once, this requiresclearMockitoCaches
to be true.