summaryrefslogtreecommitdiff
path: root/BitTimer.php
blob: dec64371b5d8dbbc442aa05da94fa871f3318cfe (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
<?php
/**
 * @version $Header$
 * Basic processes timer
 *
 * @package kernel
 */
 
/**
 * @package kernel
 */
class BitTimer {
	function parseMicro( $micro ) {
		list( $micro, $sec ) = explode( ' ', microtime() );
		return $sec + $micro;
	}

	function start( $timer = 'default' ) {
		$this->mTimer[$timer] = $this->parseMicro( microtime() );
	}

	function stop( $timer = 'default' ) {
		return $this->current( $timer );
	}

	function elapsed( $timer = 'default' ) {
		return $this->parseMicro( microtime() ) - $this->mTimer[$timer];
	}
}

/**
 * Create timer
 */
global $gBitTimer;
$gBitTimer = new BitTimer();
$gBitTimer->start();
?>