) 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;
+`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 ) NOT NULL ,
+`time` FLOAT( 10, 2 ) NOT NULL ,
+INDEX ( `function` ) ,
+INDEX ( `file` )
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
<?php
-define( 'UPDATE_VERSION' , 1131 );
+define( 'UPDATE_VERSION' , 1132 );
/**
*
/**
* CREATE TABLE for profiling
*/
-function update_1132() {\r
+function update_1131() {\r
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; ");\r
+`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 ) NOT NULL ,
+`time` FLOAT( 10, 2 ) NOT NULL ,
+INDEX ( `function` ) ,
+INDEX ( `file` )
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;");\r
}
<?php
function microtime_float()\r
{\r
- list($usec, $sec) = explode(" ", microtime());\r
- return ((float)$usec + (float)$sec);\r
+ return microtime(true);\r
}\r
\r
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'); ",\r
- floatval($time-$_SERVER['REQUEST_TIME']));
- }
-
- $elapsed=microtime_float()-$time;
-
- $db_info=array_shift(debug_backtrace());
+ $db_info=debug_backtrace();
+ $db_info=$db_info[1];
$function=$db_info['function'];
$file=$db_info['file'];
$line=$db_info['line'];
//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();
+ dbesc($function), dbesc($file), intval($line), dbesc($class), microtime_float()*1000);
}
-declare(ticks=1);\r
-register_tick_function('tick_event');
\ No newline at end of file
+register_tick_function('tick_event');\r
+declare(ticks=50);
\ No newline at end of file