aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kampmann <programmer@nurfuerspam.de>2012-03-15 11:45:06 +0100
committerAlexander Kampmann <programmer@nurfuerspam.de>2012-03-15 11:45:06 +0100
commit9796e99fa8378758c4fe0f655b7c192f8fc1690f (patch)
tree82f67ab99c3816ff66aa25c3c5f15953ecc43e5c
parent29ade1d9b971bb14746bab5ec57db0e204c9e137 (diff)
downloadvolse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.tar.gz
volse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.tar.bz2
volse-hubzilla-9796e99fa8378758c4fe0f655b7c192f8fc1690f.zip
added simple build-in profiling
-rwxr-xr-xboot.php2
-rwxr-xr-xdatabase.sql11
-rwxr-xr-xindex.php1
-rwxr-xr-xupdate.php16
-rwxr-xr-xutil/profiler.php36
5 files changed, 64 insertions, 2 deletions
diff --git a/boot.php b/boot.php
index b30f02c9f..e2494092d 100755
--- a/boot.php
+++ b/boot.php
@@ -11,7 +11,7 @@ require_once('include/cache.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '2.3.1278' );
define ( 'DFRN_PROTOCOL_VERSION', '2.22' );
-define ( 'DB_UPDATE_VERSION', 1131 );
+define ( 'DB_UPDATE_VERSION', 1132 );
define ( 'EOL', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/database.sql b/database.sql
index 35c257f02..f8d4c7fc2 100755
--- a/database.sql
+++ b/database.sql
@@ -857,4 +857,13 @@ INDEX ( `ham` ),
INDEX ( `term` )
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
-
+CREATE TABLE IF NOT EXISTS `profiling` (
+`id` INT NOT NULL AUTO_INCREMENT PRIMARY_KEY ,
+`function` VARCHAR(255) NOT NULL,
+`file` VARCHAR(255) NOT NULL,
+`line` INT NOT NULL DEFAULT '-1',
+`class` VARCHAR(255),
+`time` FLOAT(10, 2) NOT NULL,
+INDEX(`function`),
+INDEX(`file`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/index.php b/index.php
index 5f6d74adb..688eee2ee 100755
--- a/index.php
+++ b/index.php
@@ -41,6 +41,7 @@ require_once("dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
unset($db_host, $db_user, $db_pass, $db_data);
+require_once('util/profiler.php');
if(! $install) {
diff --git a/update.php b/update.php
index c29394b48..36116341a 100755
--- a/update.php
+++ b/update.php
@@ -1122,3 +1122,19 @@ function update_1130() {
q("ALTER TABLE `item` ADD `file` MEDIUMTEXT NOT NULL AFTER `inform`, ADD FULLTEXT KEY (`file`) ");
}
+/**
+ * CREATE TABLE for profiling
+ */
+function update_1132() {
+ q("CREATE TABLE IF NOT EXISTS `profiling` (
+`id` INT NOT NULL AUTO_INCREMENT PRIMARY_KEY ,
+`function` VARCHAR(255) NOT NULL,
+`file` VARCHAR(255) NOT NULL,
+`line` INT NOT NULL DEFAULT '-1',
+`class` VARCHAR(255),
+`time` FLOAT(10, 2) NOT NULL,
+INDEX(`function`),
+INDEX(`file`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8; ");
+}
+
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