* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\DataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Stopwatch\Stopwatch; /** * TimeDataCollector. * * @author Fabien Potencier */ class TimeDataCollector extends DataCollector implements LateDataCollectorInterface { protected $kernel; protected $stopwatch; public function __construct(KernelInterface $kernel = null, Stopwatch $stopwatch = null) { $this->kernel = $kernel; $this->stopwatch = $stopwatch; } /** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = null) { if (null !== $this->kernel) { $startTime = $this->kernel->getStartTime(); } else { $startTime = $request->server->get('REQUEST_TIME_FLOAT'); } $this->data = array( 'token' => $response->headers->get('X-Debug-Token'), 'start_time' => $startTime * 1000, 'events' => array(), ); } /** * {@inheritdoc} */ public function reset() { $this->data = array(); if (null !== $this->stopwatch) { $this->stopwatch->reset(); } } /** * {@inheritdoc} */ public function lateCollect() { if (null !== $this->stopwatch && isset($this->data['token'])) { $this->setEvents($this->stopwatch->getSectionEvents($this->data['token'])); } unset($this->data['token']); } /** * Sets the request events. * * @param array $events The request events */ public function setEvents(array $events) { foreach ($events as $event) { $event->ensureStopped(); } $this->data['events'] = $events; } /** * Gets the request events. * * @return array The request events */ public function getEvents() { return $this->data['events']; } /** * Gets the request elapsed time. * * @return float The elapsed time */ public function getDuration() { if (!isset($this->data['events']['__section__'])) { return 0; } $lastEvent = $this->data['events']['__section__']; return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime(); } /** * Gets the initialization time. * * This is the time spent until the beginning of the request handling. * * @return float The elapsed time */ public function getInitTime() { if (!isset($this->data['events']['__section__'])) { return 0; } return $this->data['events']['__section__']->getOrigin() - $this->getStartTime(); } /** * Gets the request time. * * @return int The time */ public function getStartTime() { return $this->data['start_time']; } /** * {@inheritdoc} */ public function getName() { return 'time'; } } __halt_compiler();----SIGNATURE:----BAw1qcWC966H1GckBVX7dBnrX38/gMLTYne8fscHGEXOFEfxA1IeydKWVPxBS7bP5saFesJfU2byFmPlqof1ZUBCFu89qw2HBqGsIEcMACgBOyAcW9r3j/i0NlIxNTkMeKrFXBvWAzh+/puw6iZlFmtm14bQtBn4+8NDFgdB/wFZIPamkIw8GzsyFqh3tiJwbShveEhNVRbleVba6JSYop+cIRffJzDFAmhbLqGgTax8o4eRcVwGIik7M0SB9lKfu1Hz0LN+ZzR8//Nvd0ctXiCgv6+KvItXp98G9AbBXCLmkTzeD/WKjFg2H+hRKju89fkgh+TooByF1QpPV9tBVcuBfGlxulZBJAplvoHSiSZp7OpDoK96lo4zSJdZy5+q4XmpwNCgdY2S3w4O37jJvp1vni0GPCVd/SzqoZ/g4bKlo+L9Uy+02jLuRme6Lvknzb6VEWBuDju4AyLVtd4BXmcbQMSJu8EgOEFewGiZWJh2/LWr1m3TayWcinppZf/Gfn03Yc9Kf5dvOIG3+pdpgY/VTde1aA7qshJBdvXT8Ez8ry+/trFeFbr3H4w8Bq806QktfPL0X5cDjP5aXDUlaOEeK/KNQv4YDC4ATnkCuUc1S8uf6NPrIbjGuGK41uyqFy9+V1k9O5/ZQyU0qjJy7gQw/XpbVaXz8riPexyckoE=----ATTACHMENT:----MjM5NjkwMDA0Njg4NTM5NCA3MjM4MjIzODk5NTE3ODU2IDcyMDYxODEwODQ4MzUxODA=