Esempio n. 1
0
 /**
  * Dummy strategy to return as order value index of the vertex
  *
  * @param OutTree $tree
  * @return array
  */
 public function optimize(OutTree $tree)
 {
     $vertices = $tree->getVerticesDescendant($tree->getVertexRoot());
     $i = 0;
     $output = [];
     /** @var Vertex $vertex */
     foreach ($vertices as $vertex) {
         $output[$vertex->getId()] = $i++;
     }
     return $output;
 }
Esempio n. 2
0
 /**
  * Optimize order of tests in given tree based on their defined delay.
  * The aim is to run as first processes having the longest delay of their sub-dependencies.
  *
  * @param OutTree $tree
  * @return array Array of [string key (= testclass fully qualified name) => int value (= test order)]
  */
 public function optimize(OutTree $tree)
 {
     // get root node of the tree
     $root = $tree->getVertexRoot();
     // get all root descendants vertices (without the root vertex itself)
     $children = $tree->getVerticesDescendant($root);
     // for each vertex (process) get maximum total weight of its subtree (longest distance)
     $subTreeMaxDistances = [];
     /** @var Vertex $childVertex */
     foreach ($children as $childVertex) {
         $alg = new Dijkstra($childVertex);
         // get map with distances to all linked reachable vertexes
         $distanceMap = $alg->getDistanceMap();
         // save the longest distance
         $subTreeMaxDistances[$childVertex->getId()] = $distanceMap ? max($distanceMap) : 0;
     }
     return $subTreeMaxDistances;
 }