friendica/util/profiler.php

21 lines
543 B
PHP
Raw Normal View History

2012-03-15 11:45:06 +01:00
<?php
function microtime_float()
{
2012-03-15 12:55:49 +01:00
return microtime(true);
2012-03-15 11:45:06 +01:00
}
function tick_event() {
2012-03-15 12:55:49 +01:00
$db_info=debug_backtrace();
$db_info=$db_info[1];
2012-03-15 11:45:06 +01:00
$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'); ",
2012-03-15 12:55:49 +01:00
dbesc($function), dbesc($file), intval($line), dbesc($class), microtime_float()*1000);
2012-03-15 11:45:06 +01:00
}
2012-03-15 12:55:49 +01:00
register_tick_function('tick_event');
declare(ticks=50);