blob: 93d2d7873fd0893af28b88a5542233b0d513dccb (
plain)
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
47
48
49
50
|
<?php
/**
* @version $Header$
* Basic processes timer
*
* @package kernel
*/
namespace Bitweaver;
/**
* @package kernel
*/
class BitTimer {
/**
* Store of active timers
* @public
*/
public $mTimer = [];
public function parseMicro( $micro ) {
list( $micro, $sec ) = explode( ' ', microtime() );
return $sec + $micro;
}
public function start( $timer = 'default' ) {
$this->mTimer[$timer] = $this->parseMicro( microtime() );
}
public function current( $timer = 'default' ) {
return $this->mTimer[$timer] ?? 0;
}
public function stop( $timer = 'default' ) {
return $this->current( $timer );
}
public function elapsed( $timer = 'default' ) {
return $this->parseMicro( microtime() ) - $this->mTimer[$timer];
}
}
/**
* Create timer
*/
global $gBitTimer;
if (!isset($gBitTimer)) {
$gBitTimer = new BitTimer();
$gBitTimer->start();
}
|