/** * @see StoreImplementationInterface::storeLog() */ public function storeLog($time, $name, $tag, $version) { $em = $this->doctrine->getEntityManager(); $log = new Log(); $log->setTime(number_format($time, 4)); $log->setName($name); $log->setTag($tag); $log->setVersion($version); $log->setExecutions(1); $em->persist($log); $em->flush(); }
private function packItem(Log $log) { $keyData = $log->getName() . $log->getVersion(); if (!isset($this->dataPacked[$keyData])) { /* * Creating the first item of the pack */ $packedLog = new Log(); $packedLog->setName($log->getName()); $packedLog->setExecutions($log->getExecutions()); $packedLog->setTag($log->getTag()); $packedLog->setTime($log->getTime()); $packedLog->setVersion($log->getVersion()); $this->dataPacked[$keyData] = $packedLog; } else { $packedLog = $this->dataPacked[$keyData]; //Just updating the average time $x = $packedLog->getExecutions() * $packedLog->getTime() + $log->getExecutions() * $log->getTime(); $w = $packedLog->getExecutions() + $log->getExecutions(); $avgPond = $x / $w; $packedLog->setTime(number_format($avgPond, 4)); $packedLog->setExecutions($w); } }