summaryrefslogtreecommitdiffstats
path: root/admin/survey/classes/class.Timer.php
blob: f659a0290499a32e5455f7aff67b1fec4e8a0b6c (plain) (blame)
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
/**
* @author 	Gorazd Veselič
* @date		Julij 2010
* @desc		Namenjen merjenju časa izvajanja posameznih funkcij 
* 
*/

class Timer {
	
	static private $timer = array(); 						# timer
	static private $_timer_output = true;					# ali timer izpiše output

	static private $_decimals = 7;							# Število decimalk
	static private $_decimals_delimit = ',';				# decimalno ločilo

		/** Starta tajmer
	 * 
	 */
	static public function StartTimer($grups=0) {
		# v header dodomo userid
		$mtime = explode(" ",microtime());
		self::$timer[$grups]['start'] = $mtime[1] + $mtime[0];
	}

	/** Vrne čas izvajanja skripte
	 * 
	 */
	static public function GetTimer($grups=0) {
		global $lang;
		# v header dodomo userid
		$mtime = explode(" ",microtime());
		self::$timer[$grups]['end'] = $mtime[1] + $mtime[0];
		if (self::$_timer_output == true && isset(self::$timer[$grups]['start'] )) {
			 $_time = number_format((self::$timer[$grups]['end']-self::$timer[$grups]['start']), self::$_decimals , self::$_decimals_delimit, ' ');
			printf($lang['srv_timer_output'],$grups,$_time);
		}
		return number_format((self::$timer[$grups]['end']-self::$timer[$grups]['start']), self::$_decimals , self::$_decimals_delimit, ' ');
	}

	/**
	 * 
	 * @param unknown_type $out
	 */
	static public function setTimerOutput($out=true) {
		self::$_timer_output = $out;
		return $out;
	}
   
}