/** * @Route /performance/list */ public function listAction() { $cache = new \Raptor\Cache\Cache('performance'); if ($cache->hasCache()) { $performance = $cache->getData(); } else { $performance = new ItemList(); } $series = array(); $performance->each(function ($key, $value) use(&$series) { $item = new ItemList(); $item->set('value', $value); $item->set('no', $key); $series[] = $item->getArray(); }); return $this->JSON(new ItemList($series)); }
public function registerLastPerformance() { $app = \Raptor\Raptor::getInstance(); $time = round($app->getTimer()->getExecutionTime(), 2); $cache = new \Raptor\Cache\Cache('performance'); if (!$cache->hasCache()) { $performance = new \Raptor\Util\ItemList(); } else { $performance = $cache->getData(); } if ($performance->size() < 20) { $performance->add($time); } else { $performance->shift(); $performance->add($time); } $cache->setData($performance); $cache->save(); }