getSleep() public method

Override the sleep interval (in microseconds).
public getSleep ( $default = null )
コード例 #1
0
 /**
  * It should throw an exception if iterations is not numeric.
  */
 public function testGetters()
 {
     $options = array('context_name' => 'my_context', 'filters' => array('filter_one', 'filter_two'), 'iterations' => 5, 'revolutions' => 6, 'parameters' => array('one' => 2), 'sleep' => 100, 'retry_threshold' => 10);
     $context = new RunnerContext('/path/to', $options);
     $this->assertEquals('/path/to', $context->getPath());
     $this->assertEquals($options['context_name'], $context->getContextName());
     $this->assertEquals($options['filters'], $context->getFilters());
     $this->assertEquals($options['iterations'], $context->getIterations());
     $this->assertEquals($options['revolutions'], $context->getRevolutions());
     $this->assertEquals(array(array($options['parameters'])), $context->getParameterSets());
     $this->assertEquals($options['sleep'], $context->getSleep());
     $this->assertEquals(10, $context->getRetryThreshold());
 }
コード例 #2
0
ファイル: Runner.php プロジェクト: stof/phpbench
 private function runIterations(RunnerContext $context, SubjectMetadata $subject, ParameterSet $parameterSet, \DOMElement $variantEl)
 {
     $iterationCount = $context->getIterations($subject->getIterations());
     $revolutionCount = $context->getRevolutions($subject->getRevs());
     $iterationCollection = new IterationCollection($subject, $parameterSet, $context->getRetryThreshold($this->retryThreshold));
     $this->logger->iterationsStart($iterationCollection);
     $iterations = $iterationCollection->spawnIterations($iterationCount, $revolutionCount);
     foreach ($iterations as $iteration) {
         $this->runIteration($iteration, $subject->getSleep());
         $iterationCollection->add($iteration);
     }
     $iterationCollection->computeStats();
     $this->logger->iterationsEnd($iterationCollection);
     while ($iterationCollection->getRejectCount() > 0) {
         $this->logger->retryStart($iterationCollection->getRejectCount());
         $this->logger->iterationsStart($iterationCollection);
         foreach ($iterationCollection->getRejects() as $reject) {
             $reject->incrementRejectionCount();
             $this->runIteration($reject, $context->getSleep($subject->getSleep()));
         }
         $iterationCollection->computeStats();
         $this->logger->iterationsEnd($iterationCollection);
     }
     $stats = $iterationCollection->getStats();
     foreach ($iterationCollection as $iteration) {
         $iterationEl = $variantEl->ownerDocument->createElement('iteration');
         $iterationEl->setAttribute('revs', $iteration->getRevolutions());
         $iterationEl->setAttribute('time-net', $iteration->getResult()->getTime());
         $iterationEl->setAttribute('time', $iteration->getResult()->getTime() / $iteration->getRevolutions());
         $iterationEl->setAttribute('z-value', $iteration->getZValue());
         $iterationEl->setAttribute('memory', $iteration->getResult()->getMemory());
         $iterationEl->setAttribute('deviation', $iteration->getDeviation());
         $iterationEl->setAttribute('rejection-count', $iteration->getRejectionCount());
         $variantEl->appendChild($iterationEl);
     }
     $statsEl = $variantEl->appendElement('stats');
     foreach ($stats as $statName => $statValue) {
         $statsEl->setAttribute($statName, $statValue);
     }
 }
コード例 #3
0
ファイル: Runner.php プロジェクト: lmaslowski/phpbench
 private function runIterations(ExecutorInterface $executor, RunnerContext $context, SubjectMetadata $subject, ParameterSet $parameterSet, \DOMElement $variantEl)
 {
     $iterationCount = $context->getIterations($subject->getIterations());
     $revolutionCount = $context->getRevolutions($subject->getRevs());
     $warmupCount = $context->getWarmup($subject->getWarmUp());
     $executorConfig = $this->executorRegistry->getConfig($context->getExecutor());
     $iterationCollection = new IterationCollection($subject, $parameterSet, $iterationCount, $revolutionCount, $warmupCount, $context->getRetryThreshold($this->retryThreshold));
     $this->logger->iterationsStart($iterationCollection);
     try {
         foreach ($iterationCollection as $iteration) {
             $this->runIteration($executor, $executorConfig, $iteration, $context->getSleep($subject->getSleep()));
         }
     } catch (\Exception $e) {
         $iterationCollection->setException($e);
         $this->logger->iterationsEnd($iterationCollection);
         $this->appendException($variantEl, $e);
         return;
     }
     $iterationCollection->computeStats();
     $this->logger->iterationsEnd($iterationCollection);
     while ($iterationCollection->getRejectCount() > 0) {
         $this->logger->retryStart($iterationCollection->getRejectCount());
         $this->logger->iterationsStart($iterationCollection);
         foreach ($iterationCollection->getRejects() as $reject) {
             $reject->incrementRejectionCount();
             $this->runIteration($executor, $executorConfig, $reject, $context->getSleep($subject->getSleep()));
         }
         $iterationCollection->computeStats();
         $this->logger->iterationsEnd($iterationCollection);
     }
     $stats = $iterationCollection->getStats();
     foreach ($iterationCollection as $iteration) {
         $iterationEl = $variantEl->ownerDocument->createElement('iteration');
         $iterationEl->setAttribute('net-time', $iteration->getResult()->getTime());
         $iterationEl->setAttribute('rev-time', $iteration->getResult()->getTime() / $iteration->getRevolutions());
         $iterationEl->setAttribute('z-value', $iteration->getZValue());
         $iterationEl->setAttribute('memory', $iteration->getResult()->getMemory());
         $iterationEl->setAttribute('deviation', $iteration->getDeviation());
         $iterationEl->setAttribute('rejection-count', $iteration->getRejectionCount());
         $variantEl->appendChild($iterationEl);
     }
     $statsEl = $variantEl->appendElement('stats');
     foreach ($stats as $statName => $statValue) {
         $statsEl->setAttribute($statName, $statValue);
     }
 }
コード例 #4
0
ファイル: Runner.php プロジェクト: dantleech/phpbench
 private function runBenchmark(ExecutorInterface $executor, RunnerContext $context, Benchmark $benchmark, BenchmarkMetadata $benchmarkMetadata)
 {
     if ($benchmarkMetadata->getBeforeClassMethods()) {
         $executor->executeMethods($benchmarkMetadata, $benchmarkMetadata->getBeforeClassMethods());
     }
     // the keys are subject names, convert them to numerical indexes.
     $subjectMetadatas = array_filter($benchmarkMetadata->getSubjects(), function ($subjectMetadata) {
         if ($subjectMetadata->getSkip()) {
             return false;
         }
         return true;
     });
     $subjectMetadatas = array_values($subjectMetadatas);
     foreach ($subjectMetadatas as $subjectMetadata) {
         // override parameters
         $subjectMetadata->setIterations($context->getIterations($subjectMetadata->getIterations()));
         $subjectMetadata->setRevs($context->getRevolutions($subjectMetadata->getRevs()));
         $subjectMetadata->setWarmup($context->getWarmup($subjectMetadata->getWarmUp()));
         $subjectMetadata->setSleep($context->getSleep($subjectMetadata->getSleep()));
         $subjectMetadata->setRetryThreshold($context->getRetryThreshold($this->retryThreshold));
         $benchmark->createSubjectFromMetadata($subjectMetadata);
     }
     $this->logger->benchmarkStart($benchmark);
     foreach ($benchmark->getSubjects() as $index => $subject) {
         $subjectMetadata = $subjectMetadatas[$index];
         $this->logger->subjectStart($subject);
         $this->runSubject($executor, $context, $subject, $subjectMetadata);
         $this->logger->subjectEnd($subject);
     }
     $this->logger->benchmarkEnd($benchmark);
     if ($benchmarkMetadata->getAfterClassMethods()) {
         $executor->executeMethods($benchmarkMetadata, $benchmarkMetadata->getAfterClassMethods());
     }
 }