o2system /
gear
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * This file is part of the O2System Framework package. |
||
| 4 | * |
||
| 5 | * For the full copyright and license information, please view the LICENSE |
||
| 6 | * file that was distributed with this source code. |
||
| 7 | * |
||
| 8 | * @author Steeve Andrian Salim |
||
| 9 | * @copyright Copyright (c) Steeve Andrian Salim |
||
| 10 | */ |
||
| 11 | |||
| 12 | // ------------------------------------------------------------------------ |
||
| 13 | |||
| 14 | namespace O2System\Gear\Profiler; |
||
| 15 | |||
| 16 | // ------------------------------------------------------------------------ |
||
| 17 | |||
| 18 | use O2System\Gear\Profiler\DataStructures\Metric; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Class Metrics |
||
| 22 | * |
||
| 23 | * @package O2System\Gear\Profiler\Collections |
||
| 24 | */ |
||
| 25 | class Metrics extends \SplQueue |
||
| 26 | { |
||
| 27 | /** |
||
| 28 | * Metrics::$logged |
||
| 29 | * |
||
| 30 | * @var array |
||
| 31 | */ |
||
| 32 | protected static $logged = []; |
||
| 33 | |||
| 34 | // ------------------------------------------------------------------------ |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Metrics::push |
||
| 38 | * |
||
| 39 | * @param Metric $metric |
||
| 40 | */ |
||
| 41 | public function push($metric) |
||
| 42 | { |
||
| 43 | $metric->stop(); |
||
| 44 | |||
| 45 | if ( ! $this->isEmpty()) { |
||
| 46 | $metric->start($this->top()->endTime, $this->top()->endMemory); |
||
| 47 | } elseif (defined('STARTUP_MEMORY')) { |
||
| 48 | $metric->start(STARTUP_TIME, STARTUP_MEMORY); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 49 | } |
||
| 50 | |||
| 51 | parent::push($metric); |
||
| 52 | } |
||
| 53 | |||
| 54 | // ------------------------------------------------------------------------ |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Metrics::current |
||
| 58 | * |
||
| 59 | * Return the current Benchmark |
||
| 60 | * |
||
| 61 | * @return Metric |
||
| 62 | */ |
||
| 63 | public function current() |
||
| 64 | { |
||
| 65 | if (null === ($current = parent::current())) { |
||
|
0 ignored issues
–
show
|
|||
| 66 | $this->rewind(); |
||
| 67 | } |
||
| 68 | |||
| 69 | return parent::current(); |
||
| 70 | } |
||
| 71 | } |