-
Notifications
You must be signed in to change notification settings - Fork 0
/
TotalDuration.php
46 lines (30 loc) · 875 Bytes
/
TotalDuration.php
1
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Debuggy\Gauger\Indicator;
use Debuggy\Gauger\Formatter;
/**
* Returns total duration of the script. Relies on the _SERVER['REQUEST_TIME_FLOAT']
*/
class TotalDuration extends Microtime {
/** {@inheritdoc} */
public function __construct ($time = null, Formatter $formatter = null) {
parent::__construct ($formatter);
if (isset ($time))
$this->_timePoint = (float) $time;
else if (isset ($_SERVER['REQUEST_TIME_FLOAT']))
$this->_timePoint = $_SERVER['REQUEST_TIME_FLOAT'];
else if (isset ($_SERVER['REQUEST_TIME']))
$this->_timePoint = $_SERVER['REQUEST_TIME'];
else
$this->_timePoint = microtime (true);
}
/** {@inheritdoc} */
public function gauge ($extra = null) {
return microtime (true) - $this->_timePoint;
}
/**
* Point of the time when the script started
*
* @var float
*/
private $_timePoint;
}