getMetricValues() public method

e.g. $variant->getMetricValues(ComputedResult::class, 'z_value');
public getMetricValues ( $resultClass, $metricName ) : mixed[]
return mixed[]
コード例 #1
0
 private function drawIterations(Variant $variant)
 {
     $subject = $variant->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 ($variant->isComputed()) {
         $times = $variant->getMetricValues(ComputedResult::class, 'z_value');
         $stats = $variant->getStats();
         $freqs = Statistics::histogram($times, $bins, -$sigma, $sigma);
     } else {
         $stats = new Distribution([0]);
         $freqs = array_fill(0, $bins + 1, null);
     }
     $this->output->write(sprintf('#%-2d (σ = %s ) -%sσ [', $subject->getIndex(), $this->timeUnit->format($stats->getStdev()), $sigma));
     $this->drawBlocks($freqs, $stats);
     $this->output->write(sprintf('] +%sσ <comment>%s</comment>', $sigma, $variant->isComputed() ? $this->formatIterationsShortSummary($variant) : ''));
     $this->output->write(PHP_EOL);
 }
コード例 #2
0
ファイル: VariantTest.php プロジェクト: dantleech/phpbench
 /**
  * It should return times and memories.
  */
 public function testGetMetricValues()
 {
     $variant = new Variant($this->subject->reveal(), $this->parameterSet->reveal(), 1, 0);
     $variant->createIteration(TestUtil::createResults(4, 100));
     $variant->createIteration(TestUtil::createResults(8, 200));
     $times = $variant->getMetricValuesByRev(TimeResult::class, 'net');
     $memories = $variant->getMetricValues(MemoryResult::class, 'peak');
     $this->assertEquals([4, 8], $times);
     $this->assertEquals([100, 200], $memories);
 }