[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Component\HttpKernel\DataCollector; 13 14 use Symfony\Component\HttpKernel\KernelInterface; 15 use Symfony\Component\HttpFoundation\Request; 16 use Symfony\Component\HttpFoundation\Response; 17 18 /** 19 * TimeDataCollector. 20 * 21 * @author Fabien Potencier <fabien@symfony.com> 22 */ 23 class TimeDataCollector extends DataCollector 24 { 25 protected $kernel; 26 27 public function __construct(KernelInterface $kernel = null) 28 { 29 $this->kernel = $kernel; 30 } 31 32 /** 33 * {@inheritdoc} 34 */ 35 public function collect(Request $request, Response $response, \Exception $exception = null) 36 { 37 if (null !== $this->kernel) { 38 $startTime = $this->kernel->getStartTime(); 39 } else { 40 $startTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME')); 41 } 42 43 $this->data = array( 44 'start_time' => $startTime * 1000, 45 'events' => array(), 46 ); 47 } 48 49 /** 50 * Sets the request events. 51 * 52 * @param array $events The request events 53 */ 54 public function setEvents(array $events) 55 { 56 foreach ($events as $event) { 57 $event->ensureStopped(); 58 } 59 60 $this->data['events'] = $events; 61 } 62 63 /** 64 * Gets the request events. 65 * 66 * @return array The request events 67 */ 68 public function getEvents() 69 { 70 return $this->data['events']; 71 } 72 73 /** 74 * Gets the request elapsed time. 75 * 76 * @return float The elapsed time 77 */ 78 public function getDuration() 79 { 80 if (!isset($this->data['events']['__section__'])) { 81 return 0; 82 } 83 84 $lastEvent = $this->data['events']['__section__']; 85 86 return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime(); 87 } 88 89 /** 90 * Gets the initialization time. 91 * 92 * This is the time spent until the beginning of the request handling. 93 * 94 * @return float The elapsed time 95 */ 96 public function getInitTime() 97 { 98 if (!isset($this->data['events']['__section__'])) { 99 return 0; 100 } 101 102 return $this->data['events']['__section__']->getOrigin() - $this->getStartTime(); 103 } 104 105 /** 106 * Gets the request time. 107 * 108 * @return int The time 109 */ 110 public function getStartTime() 111 { 112 return $this->data['start_time']; 113 } 114 115 /** 116 * {@inheritdoc} 117 */ 118 public function getName() 119 { 120 return 'time'; 121 } 122 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |