/** * Displays execution information. * * @param AggregatorInterface $aggregator */ public function update(AggregatorInterface $aggregator, $i) { printf('Executed repetitions: %s' . PHP_EOL, $i); foreach ($this->tests_titles as $index => $title) { printf('Test "%s" execution time: %f ' . PHP_EOL, $title, @end(@$aggregator->getData())[$index]); } }
/** * Updates plot data. * * @param AggregatorInterface $aggregator * @param $i * * @return mixed|void */ public function update(AggregatorInterface $aggregator, $i) { $this->plot->reset(); $this->plot->setGraphTitle($this->title); $this->plot->setXLabel('run'); $this->plot->setYLabel('time'); // set titles foreach ($this->tests_titles as $index => $title) { $this->plot->setTitle($index, $title); } foreach ($aggregator->getData() as $i => $results) { foreach ($results as $index => $resultValue) { $this->plot->push($i, $resultValue, $index); } } $this->plot->refresh(); }
private function bench($benchFunction, $i, $index) { if ($benchFunction instanceof BenchmarkInterface) { $benchFunction->setUp($i); PHP_Timer::start(); $benchFunction->execute(); $time = PHP_Timer::stop(); } else { PHP_Timer::start(); $benchFunction($i); $time = PHP_Timer::stop(); } $this->aggregator->push($i, $index, $time); }