THINKphp has the effect of debugging the running status:
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
means:
Running information: Overall execution time 0.2463s (Loading: 0.0003s Initialization: 0.0010s Execution: 0.1095s Template: 0.1355s ) | Database: 13 reads, 0 writes | Cache: 2 reads, 0 writes | Memory used: 415 kb | Files loaded: 20 | Function calls: 63 (since Definition), 1370 (built-in)
Let’s analyze how these data are obtained?
PHP gets the page execution time:
Copy code The code is as follows:
/**
* Get the current time
*/
function getMicrotime() {
list ($usec, $sec) = explode(" ", microtime());
return ((float) $usec + (float) $ sec);
}
Usage: The above method can get the current time. To calculate the page execution time, you can execute this method at the beginning and end of the program. The final time difference is the page execution. time, the principle is very simple.
Get the number of database reads and writes
Set a global variable when inserting and reading in the database. Each time the execution is successful, $i++ is once,
, which is the db class in tp method, and the N method is: a method of automatic accumulation.
Similarly, the cache is calculated in this way
Memory overhead
memory_get_usage can get the current memory consumption, which can be called at the beginning and end of the program. The difference is the memory overhead.
The number of loaded files
get_included_files: Gets the names of all files that have been included using include, include_once, require or require_once.
That is, you can get all include, require The number of files, returns the array of imported files:
Official website example":
Copy code The code is as follows:
// 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";
}
?>
The returned result is:
abc.php
test1.php
test2.php
test3.php
test4.php
Function calling method
The first one to look at is this. It feels like it automatically +1 when called in each method. But it seems unlikely. It seems that this is done every time. The writing in this method was unreliable. The group discussed it for a long time, and finally found a function in PHP:
get_defined_functions returns the array format of all methods imported into the PHP file, including custom and built-in ones.
An example of introducing the official website:
Copy the code The code is as follows:
function myrow($id, $data)
{
return "
$id | $data |
n" ;
}
$arr = get_defined_functions();
print_r($arr);
?>
The result is:
Copy code The code is as follows:
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
)
)
user is customized Method, internal is an array of built-in methods.
Extensions:
get_defined_constants Gets an array that defines all constants
get_defined_functions Gets an array that defines all functions
get_defined_vars Gets an array that defines all variables
get_declared_classes Returns already defined classes array of
http://www.bkjia.com/PHPjc/327374.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327374.htmlTechArticleTHINKphp has the effect of debugging the running status: 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 k...