| Total Complexity | 8 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | class Benchmark |
||
| 17 | { |
||
| 18 | private int $startTime; |
||
| 19 | private int $memory; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Inicia a contagem de tempo |
||
| 23 | */ |
||
| 24 | public function __construct() |
||
| 25 | { |
||
| 26 | $this->startTime = microtime(true); |
||
| 27 | $this->memory = memory_get_usage(); |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Reinicia a contagem de tempo |
||
| 32 | */ |
||
| 33 | public function reset() |
||
| 34 | { |
||
| 35 | $this->startTime = microtime(true); |
||
| 36 | $this->memory = memory_get_usage(); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Retorna o tempo gasto (em microssegundos) |
||
| 41 | * @return float |
||
| 42 | */ |
||
| 43 | private function getMicroTime() |
||
| 44 | { |
||
| 45 | return microtime(true) - $this->startTime; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Retorna o tempo gasto (na unidade correta) |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | public function getTime() |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Retorna a quantidade de memória gasta |
||
| 73 | * @return int |
||
| 74 | */ |
||
| 75 | public function getMemory() |
||
| 80 |