Class OrienteeringSelection.SequenceDetails

  • Enclosing class:
    OrienteeringSelection

    private static class OrienteeringSelection.SequenceDetails
    extends Object
    Information used by Orienteering to compute a weight for a sequence.
    • Field Detail

      • methodSizeSqrt

        private final double methodSizeSqrt
        The square root of the number of method calls in the sequence.
      • executionTimeNanos

        private final long executionTimeNanos
        The execution time of the sequence, in nanoseconds.
      • selectionCount

        private int selectionCount
        Number of times this sequence has been selected by OrienteeringSelection.
      • weight

        private double weight
        A Sequence's weight. This is computed from the other fields and is updated when selectionCount is.
    • Constructor Detail

      • SequenceDetails

        SequenceDetails​(Sequence sequence,
                        long executionTimeNanos)
        Create a SequenceDetails for the given sequence, but using the given execution time.
        Parameters:
        sequence - a sequence
        executionTimeNanos - execution time in nanoseconds
      • SequenceDetails

        public SequenceDetails​(double methodSizeSqrt,
                               long executionTimeNanos)
        Create a SequenceDetails.
        Parameters:
        methodSizeSqrt - the square root of the number of method calls
        executionTimeNanos - the execution time, in nanoseconds
    • Method Detail

      • incrementSelectionCount

        public void incrementSelectionCount()
        Increments the selection count.
      • getWeight

        public double getWeight()
        Returns the weight of the sequence.
        Returns:
        the weight of the sequence
      • updateWeight

        private void updateWeight()
        Compute the weight of a sequence. The formula for a sequence's weight is:

        1.0 / (k * seq.exec_time * sqrt(seq.meth_size))

        where k is the number of selections of seq and exec_time is the execution time of seq and meth_size is the number of method call statements in seq. This formula is a slight simplification of the one described in the GRT paper which maintains a separate exec_time for each execution of seq. However, we assume that every execution time for a sequence is the same as the first execution.