computeStats() 공개 메소드

Calculate and set the deviation from the mean time for each iteration. If the deviation is greater than the rejection threshold, then mark the iteration as rejected.
public computeStats ( )
예제 #1
0
 private function processVariant(Variant $variant, \DOMElement $variantEl, array $resultClasses)
 {
     $errorEls = $variantEl->query('.//error');
     if ($errorEls->length) {
         $errors = [];
         foreach ($errorEls as $errorEl) {
             $error = new Error($errorEl->nodeValue, $errorEl->getAttribute('exception-class'), $errorEl->getAttribute('code'), $errorEl->getAttribute('file'), $errorEl->getAttribute('line'), '');
             $errors[] = $error;
         }
         $variant->createErrorStack($errors);
         return;
     }
     foreach ($variantEl->query('./iteration') as $iterationEl) {
         $results = [];
         foreach ($iterationEl->attributes as $attributeEl) {
             $name = $attributeEl->name;
             if (false === strpos($name, '-')) {
                 throw new \RuntimeException(sprintf('Expected attribute name to have a result key prefix, got "%s".', $name));
             }
             $prefix = substr($name, 0, strpos($name, '-'));
             if (!isset($resultClasses[$prefix])) {
                 throw new \RuntimeException(sprintf('No result class was provided with key "%s" for attribute "%s"', $prefix, $name));
             }
             $suffix = substr($name, strpos($name, '-') + 1);
             $results[$prefix][str_replace('-', '_', $suffix)] = $attributeEl->value;
         }
         $iteration = $variant->createIteration();
         foreach ($results as $resultKey => $resultData) {
             $iteration->setResult(call_user_func_array([$resultClasses[$resultKey], 'fromArray'], [$resultData]));
         }
     }
     // TODO: Serialize statistics ..
     $variant->computeStats();
 }
예제 #2
0
 /**
  * It should throw an exception if getStats is called when an exception has been set.
  *
  * @expectedException RuntimeException
  * @expectedExceptionMessage Cannot retrieve stats when an exception
  */
 public function testGetStatsWithExceptionException()
 {
     $variant = new Variant($this->subject->reveal(), $this->parameterSet->reveal(), 4, 20);
     $this->subject->getRetryThreshold()->willReturn(10);
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->createIteration(TestUtil::createResults(4, 10));
     $variant->computeStats();
     $variant->setException(new \Exception('Test'));
     $variant->getStats();
 }