| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPSynchro\Utilities; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class to represent a single timer |
| 7 |
* |
| 8 |
*/ |
| 9 |
class SyncTimer |
| 10 |
{ |
| 11 |
public $desc = null; |
| 12 |
public $time_start = null; |
| 13 |
public $time_end = null; |
| 14 |
public $elapsed = 0; |
| 15 |
|
| 16 |
public function __construct() |
| 17 |
{ |
| 18 |
} |
| 19 |
|
| 20 |
public function setStart($time_as_float) |
| 21 |
{ |
| 22 |
$this->time_start = $time_as_float; |
| 23 |
} |
| 24 |
|
| 25 |
public function startNow() |
| 26 |
{ |
| 27 |
$this->time_start = microtime(true); |
| 28 |
} |
| 29 |
|
| 30 |
public function endNow() |
| 31 |
{ |
| 32 |
$this->time_end = microtime(true); |
| 33 |
$this->elapsed = $this->time_end - $this->time_start; |
| 34 |
return $this->elapsed; |
| 35 |
} |
| 36 |
|
| 37 |
public function getTimeUntilNow() |
| 38 |
{ |
| 39 |
return microtime(true) - $this->time_start; |
| 40 |
} |
| 41 |
|
| 42 |
public function getElapsed() |
| 43 |
{ |
| 44 |
return $this->elapsed; |
| 45 |
} |
| 46 |
} |
| 47 |
|