Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
Zsolt Kővári edited this page May 4, 2015 · 2 revisions

Benchmark Phases

MONDO-SAM concentrates on the executions of benchmark phases, which involve the main operations in connection with the benchmark's core functionality. A sequence of phases are executed in a certain order that depends on the structure of phases, composed in every scenario separately.

Basically two groups of phases can be distinguished. The first are the composite phases and second are the atomic phases. Every composite phase behave as a container also, including another composite or atomic one, thus creating a hierarchy, a tree structure of phases. By the usage of composite phases a special and arbitrary execution workflow can be achieved. This means that different kind of operations can be executed in any order. The class diagram below represents the relationships among phases:

Class diagram of phases

In any case, an Iterator belongs to the concrete BenchmarkPhase instance. Note that none of the composite phases actually know whether they consist atomic phases or just composite types, but the iterators do. Their task is to provide AtomicPhase objects by returning them to BenchmarkEngine, where they will be executed.

The following sections describe the functionalities of the composite phases.

Sequence Phase

A SequencePhase contains arbitrary number of BenchmarkPhase instances in a list, and every one of them is evaluated only once. A SequencePhaseIterator belongs to the class, which is able to iterate on the elements. For clarity's sake, a part of the code shown below:

public class SequencePhaseIterator implements Iterator<BenchmarkPhase> {

    private int index;
    private SequencePhase sequencePhase;
    private Iterator<BenchmarkPhase> iterator;

    public SequencePhaseIterator(SequencePhase phase) {
        this.sequencePhase = phase;
        this.iterator = sequencePhase.getPhases().getFirst().iterator();
    }

    @Override
    public AtomicPhase next() {
        int size = sequencePhase.getSize();
        // if returned the last AtomicPhase before
        if (index == size) {
            index = 0;
            iterator = sequencePhase.getPhases().getFirst().iterator();
        }

        AtomicPhase atomic = (AtomicPhase) iterator.next();
        if (iterator.hasNext() == false) {
            index++;
            if (index < size) {
                iterator = sequencePhase.getPhases().get(index).iterator();
            }
        }
        return atomic;
    }

As it is seen above, a SequenceIterator always has a reference to the SequencePhase object, and also contains another iterator as well. The latter belongs to the current phase from the list. At the end of the next() function an AtomicPhase will be returned to the BenchmarkEngine. The SequenceIterator is always instantiated by the SequencePhase. To represent:

public class SequencePhase implements BenchmarkPhase {

    protected LinkedList<BenchmarkPhase> phases;

    public SequencePhase() {
        this.phases = new LinkedList<BenchmarkPhase>();
    }

    @Override
    public Iterator<BenchmarkPhase> iterator() {
        return new SequencePhaseIterator(this);
    }
}

The further BenchmarkPhase classes use the same solutions with iterators.

Iteration Phase

Only one BenchmarkPhase belongs to the class, however that is executed more times. The limitation is defined by the maxIteration attribute.

Optional Phase

The OptionalPhase differentiates from the earlier implementations in that, the included BenchmarkPhase may not be executed at all. The condition() method defines whether an AtomicPhase will be returned or not. Note that the method is invoked once by the iterator, which means the phase will be executed at most once. The OptionalPhase class is signed as abstract, since the condition cannot be determined forward, hence, its definition is also the benchmark developer's responsibility.

Loop Phase

Similarly to the previous phase, a condition method defines whether a BenchmarPhase will be executed or not. However, in contrast of the OptionalPhase, the numbers of execution times are not limited.

Clone this wiki locally