| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | namespace Kint\Object\Representation; |
| 27: | |
| 28: | use DateTime; |
| 29: | |
| 30: | class MicrotimeRepresentation extends Representation |
| 31: | { |
| 32: | public $seconds; |
| 33: | public $microseconds; |
| 34: | public $group; |
| 35: | public $lap; |
| 36: | public $total; |
| 37: | public $avg; |
| 38: | public $i = 0; |
| 39: | public $mem = 0; |
| 40: | public $mem_real = 0; |
| 41: | public $mem_peak = 0; |
| 42: | public $mem_peak_real = 0; |
| 43: | public $hints = array('microtime'); |
| 44: | |
| 45: | public function __construct($seconds, $microseconds, $group, $lap = null, $total = null, $i = 0) |
| 46: | { |
| 47: | parent::__construct('Microtime'); |
| 48: | |
| 49: | $this->seconds = (int) $seconds; |
| 50: | $this->microseconds = (int) $microseconds; |
| 51: | |
| 52: | $this->group = $group; |
| 53: | $this->lap = $lap; |
| 54: | $this->total = $total; |
| 55: | $this->i = $i; |
| 56: | |
| 57: | if ($i) { |
| 58: | $this->avg = $total / $i; |
| 59: | } |
| 60: | |
| 61: | $this->mem = \memory_get_usage(); |
| 62: | $this->mem_real = \memory_get_usage(true); |
| 63: | $this->mem_peak = \memory_get_peak_usage(); |
| 64: | $this->mem_peak_real = \memory_get_peak_usage(true); |
| 65: | } |
| 66: | |
| 67: | public function getDateTime() |
| 68: | { |
| 69: | return DateTime::createFromFormat('U u', $this->seconds.' '.\str_pad($this->microseconds, 6, '0', STR_PAD_LEFT)); |
| 70: | } |
| 71: | } |
| 72: | |