Measurement Collection Controller

The MeasurementCollectionController (often called MCC) is the central “overlord” class responsible for tracking all registered collectors and arbiters, wrapping collectors around measured tests in the correct order, and invoking the measured code block.

Note that all collectors must be stopped in the reverse order from which they were started to maximize measurement accuracy and avoid mistakenly capturing any overheard from other collectors.

The multiple circles of hell serve as a useful mental model: each circle represents a collector that is started/stopped in a specific order.

MCC is the lowest-level api we provide, and it is possible to use this class directly:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import com.workday.warp.controllers.DefaultMeasurementCollectionController
import org.junit.jupiter.api.{Test, TestInfo}

class ExampleSpec {

  // this example manages the measurement lifecycle directly and thus uses @Test instead of @WarpTest
  @Test
  def mcc(testInfo: TestInfo): Unit = {
    val mcc = new DefaultMeasurementCollectionController(testId = testInfo)
    mcc.registerCollector(new SomeMeasurementCollector)
    // start all measurement collectors prior to running the experiment
    mcc.beginMeasurementCollection()

    // run your experiment code
    someExperiment()

    // stop all measurement collectors, persist results, other cleanup
    mcc.endMeasurementCollection()
    
    // alternate signature that allows for manually specifying elapsed test time and a test timing threshold
    // mcc.endMeasurementCollection(elapsedTime = 5.seconds, threshold = 6.seconds)
  }
}

The DSL encapsulates the above sequence of operations in a more convenient API and provides some higher-level configuration options, such as distributing multiple test invocations onto a threadpool.