aboutsummaryrefslogtreecommitdiffstats
path: root/util/profiler.php
blob: fe33fe429d6762c9c99fc421569abdd10f9da775 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
function microtime_float()
{
	return microtime(true);
}

function tick_event() {
	$db_info=debug_backtrace(); 
	$db_info=$db_info[1]; 
	$function=$db_info['function']; 
	$file=$db_info['file'];
	$line=$db_info['line'];
	$class=$db_info['class'];
	
	//save results
	q("INSERT INTO `profiling` (`function`, `file`, `line`, `class`, `time`) VALUES ('%s', '%s', '%d', '%s', '%f'); ", 
			dbesc($function), dbesc($file), intval($line), dbesc($class), microtime_float()*1000); 
}

register_tick_function('tick_event');
declare(ticks=50);