THINKphp里面有调试运行状态的效果:
Process:0.2463s (Load:0.0003s Init:0.0010s Exec:0.1095s Template:0.1355s )|DB:13 queries 0 writes| Cache:2 gets,0 writes|UseMem:415 kb|LoadFile:20|CallFun:63,1370
代表的含义:
运行信息: 整体执行时间0.2463s ( 加载:0.0003s 初始化:0.0010s 执行:0.1095s 模板:0.1355s ) | 数据库 :13次读操作 0次写操作 | 缓存:2次读取,0次写入 | 使用内存:415 kb | 加载文件:20 | 函数调用:63(自定义),1370(内置)
下面来分析一下这些数据是怎么获取到的?
PHP获取页面执行时间:
复制代码 代码如下:
/**
* 得到当前时间
*/
function getMicrotime() {
list ($usec, $sec) = explode(" ", microtime());
return ((float) $usec + (float) $sec);
}
复制代码 代码如下:
// This file is abc.php
include 'test1.php';
include_once 'test2.php';
require 'test3.php';
require_once 'test4.php';
$included_files = get_included_files();
foreach ($included_files as $filename) {
echo "$filenamen";
}
?>
复制代码 代码如下:
function myrow($id, $data)
{
return "
复制代码 代码如下:
Array
(
[internal] => Array
(
[0] => zend_version
[1] => func_num_args
[2] => func_get_arg
[3] => func_get_args
[4] => strlen
[5] => strcmp
[6] => strncmp
...
[750] => bcscale
[751] => bccomp
)
[user] => Array
(
[0] => myrow
)
)