diff options
author | Alexander Kampmann <programmer@nurfuerspam.de> | 2012-03-15 11:45:06 +0100 |
---|---|---|
committer | Alexander Kampmann <programmer@nurfuerspam.de> | 2012-03-15 11:45:06 +0100 |
commit | 9796e99fa8378758c4fe0f655b7c192f8fc1690f (patch) | |
tree | 82f67ab99c3816ff66aa25c3c5f15953ecc43e5c /util | |
parent | 29ade1d9b971bb14746bab5ec57db0e204c9e137 (diff) | |
download | volse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.tar.gz volse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.tar.bz2 volse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.zip |
added simple build-in profiling
Diffstat (limited to 'util')
-rwxr-xr-x | util/profiler.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/util/profiler.php b/util/profiler.php new file mode 100755 index 000000000..3a3de5373 --- /dev/null +++ b/util/profiler.php @@ -0,0 +1,36 @@ +<?php +function microtime_float()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+function tick_event() { + static $time = NULL; + + if(NULL===$time) { + //initialise time with now + $time=microtime_float(); + + q("INSERT INTO `profiling` (`function`, `file`, `line`, `class`, `time`) VALUES ('initialization', 'index.php', '-1', NULL, '%f'); ",
+ floatval($time-$_SERVER['REQUEST_TIME'])); + } + + $elapsed=microtime_float()-$time; + + $db_info=array_shift(debug_backtrace()); + $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), floatval($time)); + + //set time to now + $time=microtime_float(); +} + +declare(ticks=1);
+register_tick_function('tick_event');
\ No newline at end of file |