Example #1
0
 public function formatIterationsShortSummary(IterationCollection $iterations)
 {
     $stats = $iterations->getStats();
     $timeUnit = $this->timeUnit->resolveDestUnit($iterations->getSubject()->getOutputTimeUnit());
     $mode = $this->timeUnit->resolveMode($iterations->getSubject()->getOutputMode());
     return sprintf('[μ Mo]/r: %s %s μRSD/r: %s%%', $this->timeUnit->format($stats['mean'], $timeUnit, $mode, null, false), $this->timeUnit->format($stats['mode'], $timeUnit, $mode, null, false), number_format($stats['rstdev'], 2));
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function iterationsEnd(IterationCollection $iterations)
 {
     $stats = $iterations->getStats();
     $timeUnit = $iterations->getSubject()->getOutputTimeUnit();
     if (null === $timeUnit || $this->timeUnit->isOverridden()) {
         $timeUnit = $this->timeUnit->getDestUnit();
     }
     $suffix = TimeUnit::getSuffix($timeUnit);
     $this->output->write(sprintf("\tμ/r: %s%s\tμSD/r %s%s\tμRSD/r: %s%%", number_format(TimeUnit::convert($stats['mean'], TimeUnit::MICROSECONDS, $timeUnit), 3), $suffix, number_format(TimeUnit::convert($stats['stdev'], TimeUnit::MICROSECONDS, $timeUnit), 3), $suffix, number_format($stats['rstdev'], 2)));
     $this->output->write(PHP_EOL);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function iterationsEnd(IterationCollection $iterations)
 {
     if ($iterations->hasException()) {
         $this->output->write(sprintf("    %-30s<error>ERROR</error>", $iterations->getSubject()->getName()));
         $this->output->write(PHP_EOL);
         return;
     }
     $stats = $iterations->getStats();
     $timeUnit = $iterations->getSubject()->getOutputTimeUnit();
     $mode = $iterations->getSubject()->getOutputMode();
     $this->output->write(sprintf("\tμ/r: %s\tμSD/r %s\tμRSD/r: %s%%", $this->timeUnit->format($stats['mean'], $this->timeUnit->resolveDestUnit($timeUnit), $this->timeUnit->resolveMode($mode)), $this->timeUnit->format($stats['stdev'], $this->timeUnit->resolveDestUnit($timeUnit), TimeUnit::MODE_TIME), number_format($stats['rstdev'], 2)));
     $this->output->write(PHP_EOL);
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function iterationsEnd(IterationCollection $iterations)
 {
     if ($iterations->getRejectCount() > 0) {
         return;
     }
     $stats = $iterations->getStats();
     $subject = $iterations->getSubject();
     $timeUnit = $subject->getOutputTimeUnit();
     if (null === $timeUnit || $this->timeUnit->isOverridden()) {
         $timeUnit = $this->timeUnit->getDestUnit();
     }
     $suffix = TimeUnit::getSuffix($timeUnit);
     $this->output->writeln(sprintf("\t%-30s P%s\tμ/r: %s%s\tμSD/r %s%s\tμRSD/r: %s%%", $subject->getName(), $iterations->getParameterSet()->getIndex(), number_format(TimeUnit::convert($stats['mean'], TimeUnit::MICROSECONDS, $timeUnit), 3), $suffix, number_format(TimeUnit::convert($stats['stdev'], TimeUnit::MICROSECONDS, $timeUnit), 3), $suffix, number_format($stats['rstdev'], 2)));
 }
Example #5
0
 /**
  * {@inheritdoc}
  */
 public function iterationsEnd(IterationCollection $iterations)
 {
     if ($iterations->getRejectCount() > 0) {
         return;
     }
     $subject = $iterations->getSubject();
     if ($iterations->hasException()) {
         $this->output->writeln(sprintf("\t%-30s <error>ERROR</error>", $subject->getName()));
         return;
     }
     $stats = $iterations->getStats();
     $timeUnit = $subject->getOutputTimeUnit();
     $outputMode = $subject->getOutputMode();
     $this->output->writeln(sprintf("\t%-30s I%s P%s\tμ/r: %s\tμSD/r %s\tμRSD/r: %s%%", $subject->getName(), $iterations->count(), $iterations->getParameterSet()->getIndex(), $this->timeUnit->format($stats['mean'], $timeUnit, $outputMode), $this->timeUnit->format($stats['stdev'], $timeUnit, TimeUnit::MODE_TIME), number_format($stats['rstdev'], 2)));
 }
 /**
  * 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()
 {
     $iterations = new IterationCollection($this->subject->reveal(), $this->parameterSet->reveal(), 1, 1, 0);
     $iterations[0]->setResult(new IterationResult(4, null));
     $iterations->computeStats();
     $iterations->setException(new \Exception('Test'));
     $iterations->getStats();
 }
Example #7
0
 private function drawIterations(IterationCollection $iterations)
 {
     $subject = $iterations->getSubject();
     $this->output->write("");
     // clear the whole line
     $this->output->write(PHP_EOL);
     $this->output->write("");
     // clear the whole line
     $this->output->write("");
     $sigma = 2;
     $bins = 16;
     if ($iterations->isComputed()) {
         $times = $iterations->getZValues();
         $stats = $iterations->getStats();
         $freqs = Statistics::histogram($times, $bins, -$sigma, $sigma);
     } else {
         $stats = array('stdev' => 0, 'mean' => 0, 'max' => 0);
         $freqs = array_fill(0, $bins + 1, null);
     }
     $this->output->write(sprintf('#%-2d (σ = %s ) -%sσ [', $subject->getIndex(), $this->timeUnit->format($stats['stdev']), $sigma));
     $this->drawBlocks($freqs, $stats);
     $this->output->write(sprintf('] +%sσ <comment>%s</comment>', $sigma, $iterations->isComputed() ? $this->formatIterationsShortSummary($iterations) : ''));
     $this->output->write(PHP_EOL);
 }